java - Spring Boot 和 ENUM 导致非法反射访问操作

标签 java spring spring-boot exception enums

我使用 Spring Boot,以 NEO4J 作为数据库。我正在使用 Java 13 和 Spring 2.3.1。我的代码中有一个枚举:

package uk.co.osiris.entities;

public enum Involvement {
    Master,
    Charterer, 
    Owner,
    DesponentOwner,
    Agent, 
    Inspector,
    PortAuthority, 
    Other
}

它不在 NodeEntity 或 RelationshipEnity 中使用。事实上,这个枚举只是在类路径中。它没有在任何地方使用。

当我运行该应用程序时,我得到:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/home/adrian/.m2/repository/org/springframework/spring-core/5.2.7.RELEASE/spring-core-5.2.7.RELEASE.jar) to field java.lang.Enum.name
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
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

我可以,对他们来说也可能会,只需删除枚举即可。

但是为什么我会得到这个?

最佳答案

WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/home/adrian/.m2/repository/org/springframework/spring-core/5.2.7.RELEASE/spring-core-5.2.7.RELEASE.jar) to field java.lang.Enum.name
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
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

据我所知,这(仅)是使用 Java 11+ 时 Spring 中出现问题的警告。不过,据我所知,目前一切都应该运行良好。

但是,Spring 应该解决这个问题,以确保一旦非法访问操作被拒绝,该框架也可以与 future 的 Java 版本一起使用。

考虑提交 Spring 框架的问题(或检查是否已经存在问题)。

关于java - Spring Boot 和 ENUM 导致非法反射访问操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62383718/

相关文章:

java - GWT:无法从我的 onmoduleload 调用 mymain.html 类中的 javascript 方法

java - JAVA如何增加word文件中表格的列宽

java - 拆分操作栏不透明

java - Tomcat 中的 Spring @Autowired 和 WebApplicationContext

java - 为什么 Spring Boot Application 类需要有 @Configuration 注解?

java - 为 Spring Web 客户端禁用 SSL 检查

java - Spring 测试上下文最佳实践

java - 如何修复代码中的列对齐?

java - Spring boot Jpa api调用时绑定(bind)数据源

java - Spring 上下文中未加载 Spring Boot 全局 Controller 建议