2017-10-10 132 views
10

我的JDK 9 + 181春季啓動2.0.0.BUILD-快照CLI應用程序顯示此警告在啓動時:

WARNING: An illegal reflective access operation has occurred 
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/home/jan/src/fm-cli/target/fm-cli-0.1.0-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-5.0.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$1 

這是一個控制檯應用程序,所以我需要禁用此警告 - 我該怎麼做?

注意:這個問題詢問如何禁用Spring引發的這個警告的具體問題;它不是JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState的副本,它處理不同庫中的類似症狀。

回答

13

下面的選項添加到JVM從Spring的使用CGLIB禁用警告:

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

例如:

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

無需彙報;這是一個known Spring bug

發生這種情況是因爲新的JDK 9模塊系統檢測到將來(近)將來不允許的非法訪問。你可以閱讀更多關於the JDK 9 Module system here

+0

我使用JDK 9.0.4的Spring Boot 2.0.0.RC1,並面臨同樣的問題。你能解釋更多關於這個技巧嗎? ***切換***的意思是什麼? –

+0

我也在這裏看到它https://github.com/dsyer/spring-boot-java-9。我很難用IntelliJ IDEA的JVM選項。我不知道如何克服。 –

+1

@DoNhuVy - 考慮問一個關於如何做到這一點的新問題。你可以在這裏找到更多的信息:https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties –