java - 在 Java 11 上运行 Spring Boot "Hello World"?

标签 java spring-boot java-module java-11

我正在开始使用 Spring Boot。我正在做example Hello World application from the official getting started page 。当我得到我的 HelloController 的时候和我的Application我想用 ./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar 运行它,我得到了异常

2018-12-01 18:04:26.324 ERROR 4581 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted
Caused by: java.lang.IllegalAccessError: class org.apache.catalina.startup.WebAnnotationSet (in unnamed module @0x2f1f99d1) cannot access class javax.annotation.security.DeclareRoles (in module java.annotation) because module java.annotation does not export javax.annotation.security to unnamed module @0x2f1f99d1
        at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:258) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:88) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.Tomcat$FixContextListener.lifecycleEvent(Tomcat.java:973) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted

2018-12-01 18:04:26.328 ERROR 4581 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:366) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at hello.Application.main(Application.java:14) ~[classes!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[gs-spring-boot-0.1.0.jar:na]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[gs-spring-boot-0.1.0.jar:na]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[gs-spring-boot-0.1.0.jar:na]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[gs-spring-boot-0.1.0.jar:na]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:950) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 8 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted
Caused by: java.lang.IllegalAccessError: class org.apache.catalina.startup.WebAnnotationSet (in unnamed module @0x2f1f99d1) cannot access class javax.annotation.security.DeclareRoles (in module java.annotation) because module java.annotation does not export javax.annotation.security to unnamed module @0x2f1f99d1
        at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:258) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:88) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.Tomcat$FixContextListener.lifecycleEvent(Tomcat.java:973) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted

2018-12-01 18:04:26.329  INFO 4581 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-12-01 18:04:26.333  WARN 4581 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt:org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2018-12-01 18:04:26.349  INFO 4581 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-01 18:04:26.356 ERROR 4581 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at hello.Application.main(Application.java:14) ~[classes!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[gs-spring-boot-0.1.0.jar:na]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[gs-spring-boot-0.1.0.jar:na]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[gs-spring-boot-0.1.0.jar:na]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[gs-spring-boot-0.1.0.jar:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        ... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:366) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        ... 21 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 23 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 25 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:950) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 27 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 29 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:950) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 8 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted
Caused by: java.lang.IllegalAccessError: class org.apache.catalina.startup.WebAnnotationSet (in unnamed module @0x2f1f99d1) cannot access class javax.annotation.security.DeclareRoles (in module java.annotation) because module java.annotation does not export javax.annotation.security to unnamed module @0x2f1f99d1
        at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:258) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:88) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.startup.Tomcat$FixContextListener.lifecycleEvent(Tomcat.java:973) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 6 common frames omitted

我猜是because module java.annotation does not export javax.annotation.security to unnamed module @0x2f1f99d1 ,事实上,我试图在 Java 11 上运行它,这意味着应该采取一些措施让模块互相看到,但到底是什么?

设置sourceCompatibilitytargetCompatibility11 (与指南中的 1.8 相反)在 build.gradle 中没有帮助。将类路径设置为 "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.RELEASE" 也没有.

我还缺少什么?

最佳答案

首先,您可以使用 VM arg

--add-exports java.annotation/javax.annotation.security=ALL-UNNAMED

但为了 future ,您实际上应该研究类 org.apache.catalina.startup.WebAnnotationSet 的实现至于为什么它要从java.annotation访问类模块javax.annotation.security.DeclareRoles .

在模块系统中,可以查看原因org.apache.catalina.startup.WebAnnotationSet正在解析到类路径中,因为如果它位于模块路径中,您就不会看到该错误。也许某些直接/传递引入它的依赖项没有放置在模块路径上。

关于java - 在 Java 11 上运行 Spring Boot "Hello World"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53573297/

相关文章:

java - 提出名称 'servlet' : serve + let 的想法是什么

java - 为什么 java.text.Normalizer 不适用于我的 Android 应用程序?

java - setHorizo​​ntalAlignment(CENTER) - CENTER 无法解析为变量

amazon-web-services - 使用 AWS SES SMTP-错误 554 消息被拒绝 : Email address is not verified. 以下身份未通过区域 checkin

java - Java 9 模块的目录布局

java - 使用测试代码修补 Java 9 模块以处理反射

java - 在java混淆中创建对象对象

osgi - Spring Boot 可以与 OSGi 一起使用吗?如果没有,是否有计划使用 OSGi Spring Boot?

java - Spring boot - 首先初始化数据源

java - jlink 打包当前平台的二进制文件