我在用STS。
这是我的主修课:
@EnableZuulProxy
@SpringBootApplication
public static void main(String[] args) {
try {
SpringApplication.run(DevProxyApp.class, args);
}catch(Exception e) {
}
}
}下面是我的build.gradle:
buildscript {
ext {
springBootVersion = '2.0.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'pmd'
id 'org.sonarqube' version '2.6.2'
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
mainClassName = 'com.siemens.mindsphere.devproxy.DevProxyApp'
group = 'mindsphere'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
ext {
springCloudVersion = 'Finchley.BUILD-SNAPSHOT'
}
jar {
baseName = 'sdk-devproxy'
doLast {
}
destinationDir = file("$buildDir/libs/mindsphere/sdk-devproxy/$project.version/")
}
dependencies {
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-parent', version: 'Edgware.SR3', ext: 'pom'
compile('org.springframework.cloud:spring-cloud-starter-oauth2')
compile('org.springframework.cloud:spring-cloud-starter-netflix-zuul')
compile('org.springframework.boot:spring-boot-starter-web')
compile group: 'com.auth0', name: 'java-jwt', version: '3.3.0'
compile('com.auth0:java-jwt')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}我还尝试了以下依赖关系:
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '1.2.1.RELEASE', ext: 'pom'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-parent', version: 'Edgware.SR3', ext: 'pom'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-oauth2', version: '1.0.0.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zuul', version: '1.4.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.9.RELEASE'
implementation 'org.slf4j:slf4j-api:1.7.25'
compile group: 'com.auth0', name: 'java-jwt', version: '3.3.0'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}每当我以spring引导应用程序的形式运行应用程序时,它都会给出以下错误:
Error: Could not find or load main class com.siemens.mindsphere.devproxy.DevProxyApp在作为java应用程序运行时,它正在开始工作,但是使用这种启动功能(oauth2、zuul路由功能)无法工作。
我试过以下几点,但问题仍然存在:
如果你需要任何其他信息来解决这个问题,请告诉我。
FYI以前是一个maven项目,工作很好,现在我通过添加build.gradle、gradle项目等将其作为gradle项目,并删除了pom.xml。Gradle构建正在正常进行。
是否存在与jar兼容的问题??
发布于 2018-05-28 14:06:51
尝试添加一个清单属性:
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.siemens.mindsphere.devproxy.DevProxyApp'
)
}
}发布于 2018-05-29 20:19:51
试着降低springBootVersion的评级。我有这个问题,这个问题解决了。
https://stackoverflow.com/questions/50567889
复制相似问题