我正在使用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 boot app运行时,它会给我以下错误:
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兼容性问题????
答案 0 :(得分:1)
尝试添加清单属性:
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.siemens.mindsphere.devproxy.DevProxyApp'
)
}
}
答案 1 :(得分:0)
尝试降级springBootVersion。 我有这个问题,这解决了它。