springBootVersion =' 2.0.0.M6'在使用java9

时间:2017-11-08 15:47:40

标签: java spring-boot

尝试使用带有java 9的Spring启动版本2.0.0.M6启动基本应用程序,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

1 个答案:

答案 0 :(得分:0)

删除org.springframework.boot:spring-boot-starter-tomcat解决了这个问题。

org.springframework.boot:spring-boot-starter-web包含spring-boot-starter-tomcat,因此无需单独添加它。

Spring boot 2.0.0.M6 with gradle 4.3和java 9现在运行正常。