netty运行测试类时报错:Unrecognized option: --illegal-access=deny

netty(4.1.42.Final )运行netty-buffer模块测试类时报错:Unrecognized option: --illegal-access=deny

 Unrecognized option: --illegal-access=deny Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

解题思路:

1、搜了下illegal-access=deny,发现是为了管理反射非extend包,jdk9之后加的,我用的jdk是8,所以没有就对了。

2、全局搜了下--illegal-access。发现在netty-parent的pom文件里的<profiles>中配置了。正好应了下面那句很随意的回答,然后我注释了id为java11的profiles,果然可以正常运行了。

 

 3、那为啥呢?百度了下maven profiles标签的用途:https://blog.csdn.net/sr0701/article/details/124109287

发现问题在于:使用jdk11的时候激活profile配置。那么就明朗了,idea默认使用jdk11,所以……

 ……………………………………………总结:…………………………………………………………………

 解决方案:注释掉netty-parent的pom文件里的id为java11的profile

 

posted @ 2023-05-12 19:41  田海超  阅读(198)  评论(0编辑  收藏  举报