使用 Tomcat 9 和 Java10 停止 Spring Boot Web 应用程序时的非法反射访问
Illegal reflective access when I stop SpringBoot web application with Tomcat 9 and Java10
我正在使用 Spring Boot 2 尝试 Java 10 开发,但我遇到了一些问题。
该应用程序是一个基于 Spring Boot 2 的简单 Web 应用程序。应用程序启动正常,但当我停止它时,我收到此警告:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/C:/Users/CS/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.11/tomcat-embed-core-9.0.11.jar) to field java.io.ObjectStreamClass$Caches.localDescs
WARNING: Please consider reporting this to the maintainers of org.apache.catalina.loader.WebappClassLoaderBase
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
如您所见,我已经将嵌入式 Tomcat 服务器从版本 8 切换到 9.0.11 以与 Java 模块系统兼容。并且应用程序使用 --add-opens java.base/java.lang=ALL-UNNAMED
选项启动
有人知道我为什么收到这条消息吗?
要消除这些警告,您需要在启动脚本中添加以下选项:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
正如您在 Tomcat 9 startup script 中看到的那样。
警告的修复是not likely to be addressed anytime soon:
Are there plans to address these in a future release?
暂时没有。
我们会尽可能长时间地保留明确的清理。一旦它
被永久封锁我们可能不得不依赖这样一个事实
有问题的地图使用 WeakReference 并等待 GC 清除
参考。这将使追踪真正的内存泄漏变得更加困难
所以我们得看看能否说服 JRE 团队提供一些
某种替换 API if/when 我们达到了这一点。
我正在使用 Spring Boot 2 尝试 Java 10 开发,但我遇到了一些问题。
该应用程序是一个基于 Spring Boot 2 的简单 Web 应用程序。应用程序启动正常,但当我停止它时,我收到此警告:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/C:/Users/CS/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.11/tomcat-embed-core-9.0.11.jar) to field java.io.ObjectStreamClass$Caches.localDescs
WARNING: Please consider reporting this to the maintainers of org.apache.catalina.loader.WebappClassLoaderBase
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
如您所见,我已经将嵌入式 Tomcat 服务器从版本 8 切换到 9.0.11 以与 Java 模块系统兼容。并且应用程序使用 --add-opens java.base/java.lang=ALL-UNNAMED
有人知道我为什么收到这条消息吗?
要消除这些警告,您需要在启动脚本中添加以下选项:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
正如您在 Tomcat 9 startup script 中看到的那样。
警告的修复是not likely to be addressed anytime soon:
Are there plans to address these in a future release?
暂时没有。
我们会尽可能长时间地保留明确的清理。一旦它 被永久封锁我们可能不得不依赖这样一个事实 有问题的地图使用 WeakReference 并等待 GC 清除 参考。这将使追踪真正的内存泄漏变得更加困难 所以我们得看看能否说服 JRE 团队提供一些 某种替换 API if/when 我们达到了这一点。