我使用 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/