springBootVersion=&x27;2.0.0.M6和x27;开始使用java9后立即失败

springBootVersion=&x27;2.0.0.M6和x27;开始使用java9后立即失败,java,spring-boot,Java,Spring Boot,试图用spring boot 2.0.0.M6版本和java 9、gradle 4.3启动基本应用程序,但启动后立即关闭 build.gradle文件如下所示 buildscript { ext { springBootVersion = '2.0.0.M6' } repositories { mavenCentral() maven { url "https://repo.spring.io/snapshot" }

试图用spring boot 2.0.0.M6版本和java 9、gradle 4.3启动基本应用程序,但启动后立即关闭

build.gradle文件如下所示

buildscript {
    ext {
        springBootVersion = '2.0.0.M6'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'

group = 'test.com'
version = '0.0.1-SNAPSHOT'
sourceCompatibility =9.0

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

configurations {
    providedRuntime
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-web-services')
    runtime('org.springframework.boot:spring-boot-devtools')
    compileOnly('org.projectlombok:lombok')
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
2017-11-08 16:31:01.268  INFO 7704 --- [  restartedMain] dk.danskespil.ebu.EbuApplication         : No active profile set, falling back to default profiles: default

2017-11-08 16:31:01.369  INFO 7704 --- [  restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@52c4a7bc: startup date [Wed Nov 08 16:31:01 CET 2017]; root of context hierarchy

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/amga/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.1.RELEASE/1e0344e553a5ff714f299096216769beffd0d291/spring-core-5.0.1.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)

WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

2017-11-08 16:31:02.876  INFO 7704 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729

2017-11-08 16:31:02.913  INFO 7704 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup

2017-11-08 16:31:02.932  INFO 7704 --- [  restartedMain] dk.danskespil.ebu.EbuApplication         : Started EbuApplication in 2.556 seconds (JVM running for 4.056)

2017-11-08 16:31:02.936  INFO 7704 --- [       Thread-7] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@52c4a7bc: startup date [Wed Nov 08 16:31:01 CET 2017]; root of context hierarchy

2017-11-08 16:31:02.939  INFO 7704 --- [       Thread-7] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
控制台看起来像这样

buildscript {
    ext {
        springBootVersion = '2.0.0.M6'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'

group = 'test.com'
version = '0.0.1-SNAPSHOT'
sourceCompatibility =9.0

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

configurations {
    providedRuntime
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-web-services')
    runtime('org.springframework.boot:spring-boot-devtools')
    compileOnly('org.projectlombok:lombok')
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
2017-11-08 16:31:01.268  INFO 7704 --- [  restartedMain] dk.danskespil.ebu.EbuApplication         : No active profile set, falling back to default profiles: default

2017-11-08 16:31:01.369  INFO 7704 --- [  restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@52c4a7bc: startup date [Wed Nov 08 16:31:01 CET 2017]; root of context hierarchy

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/amga/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.1.RELEASE/1e0344e553a5ff714f299096216769beffd0d291/spring-core-5.0.1.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)

WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

2017-11-08 16:31:02.876  INFO 7704 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729

2017-11-08 16:31:02.913  INFO 7704 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup

2017-11-08 16:31:02.932  INFO 7704 --- [  restartedMain] dk.danskespil.ebu.EbuApplication         : Started EbuApplication in 2.556 seconds (JVM running for 4.056)

2017-11-08 16:31:02.936  INFO 7704 --- [       Thread-7] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@52c4a7bc: startup date [Wed Nov 08 16:31:01 CET 2017]; root of context hierarchy

2017-11-08 16:31:02.939  INFO 7704 --- [       Thread-7] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

删除org.springframework.boot:springbootstartertomcat解决了这个问题

boot:springbootstarterweb包含springbootstartertomcat,所以不需要单独添加它


带有gradle 4.3和java 9的Spring boot 2.0.0.M6现在可以正常工作。

拆卸如何解决问题?我尝试只使用spring boot starter web启动应用程序,它运行起来没有任何问题。然后阅读spring boot starter tomcat和starter web dependencies的目的,在build.gradle中注释了以下代码://providedRuntime('org.springframework.boot:spring boot starter tomcat')实际上我不明白为什么将两者结合在一起会有问题,但移除它并确保starter web中有一个容器解决了问题。