Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1

旧城冷巷雨未停 提交于 2019-11-28 17:12:32

In JDK 9+, add the following option to the JVM to disable the warning from Spring's use of CGLIB:

--add-opens java.base/java.lang=ALL-UNNAMED

for example:

java --add-opens java.base/java.lang=ALL-UNNAMED -jar target/*.jar

No need to report it; it's a known Spring bug.

This happens because the new JDK 9 module system detected an illegal access that will be disallowed sometime in the (near) future. You can read more about the JDK 9 Module system here.

Update:

A fix for this issue is available JDK 9+ with Spring 5.1+.

Adding to Jan Nielsen answer above, if you are using Intellij and Spring Boot 2.0.3, which depends on Spring core 5.0.7, you are still stuck and do not have the fix.

The way out for me needed two things:

  • Add the --add-opens mentioned by Jan to your run/debug configuration. Just edit the configuration and look under Environment / VM Options. This takes care of silencing some of the "illegal access messages".

  • I also needed to add a dependency to the jaxb-api library. I got the hint from ValentinBossi comment on this spring github issue.

When using the spring initializer, make sure you use the latest version of Spring Boot. It automatically gets Spring core 5.1 or greater for you and you won't see the error when you run the project.

So you don't have to worry about editing any JVM configuration.

After these warnings, if your app is still not working then add this dependency to your pom.xml

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

This helped me!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!