Java 11升级缺少javax.annotation.security

时间:2018-10-29 13:26:06

标签: java spring-boot tomcat gradle

我要升级到Java 11,是一个春季启动应用程序。war文件部署在最新的tomcat 9中,该软件以open-jdk-11开始。

该代码仍在Java 8中编译。首先使其全部在Java 11上可运行,然后从模块hazzle开始...

因此,我添加了compile 'javax.annotation:javax.annotation-api:1.3.2'作为依赖项,但以tomcat的收益率开始(启动可运行的jar会得到相同的结果):

Caused by: java.lang.IllegalAccessError: class org.apache.catalina.startup.WebAnnotationSet (in unnamed module @0x51d8cbdd) cannot access class javax.annotation.security.DeclareRoles (in module java.annotation) because module java.annotation does not export javax.annotation.security to unnamed module @0x51d8cbdd
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]
        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.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at java.lang.Thread.run(Thread.java:834) ~[?:?]

1 个答案:

答案 0 :(得分:2)

您正在运行哪个版本的Spring Boot? Java 11支持始于2.1 https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes

  

Java 11支持

     

Spring Boot 2.1仍与Java 8兼容,但现在也支持Java11。我们已配置了持续集成,以针对最新的Java 11版本构建和测试Spring Boot。