问题:WARNING: An illegal reflective access operation has occurred

问题描述

pull了一个项目,环境是jdk11.0.6,而我之前使用的是1.8。当然这都是小问题,关键是配置好环境后,启动时会弹出这么一个警告。暂时不知道会有什么影响,不过还是找了一下解决方法。

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/D:/Java/solfware/Maven/maven_repository/org/springframework/spring-core/5.2.0.RELEASE/spring-core-5.2.0.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
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

解决办法

1.配置VM option

输入:–illegal-access=deny
--illegal-access=deny
然后重启项目,将不再弹出警告,目前还不太清楚原理,或许只是掩耳盗铃。但是先用着,如果有发现问题再更新。

2.在启动类加入一个方法

因为不太喜欢这种做法,我自己用了上面的方法。这里就不写了,如果想了解的可以看我下面给的参考链接。

参考(感谢):

链接: https://weiku.co/article/351/


版权声明:本文为kamohu原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。