JVM 参数

:memo: 如何在不同环境添加该参数

根据你的开发环境,添加方式略有不同,但核心参数一致:

环境 配置位置 示例代码
IntelliJ IDEA RunEdit ConfigurationsVM options --add-opens java.base/java.util=ALL-UNNAMED
Maven (Surefire) pom.xmlmaven-surefire-plugin<argLine> <argLine>--add-opens java.base/java.util=ALL-UNNAMED</argLine>
Gradle build.gradletest 任务的 jvmArgs test { jvmArgs '--add-opens java.base/java.util=ALL-UNNAMED' }
命令行/Docker java 命令中,-jar 之前 java --add-opens java.base/java.util=ALL-UNNAMED -jar your-app.jar

:gem_stone: 常用参数

--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.time=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED