Agu*_*uid 5 migration module openjdk-17
当我从 java8 迁移到 java 17 时,我的单元测试失败。以下是我得到的异常示例:
无法使 java.io.OptionalDataException(boolean) 可访问:模块 java.base 不会向未命名模块“打开 java.io”
当我用 google 搜索时,我发现我必须添加“--add-opens java.base/java.io=ALL-UNNAMED”选项作为 JVM 的参数。
这是我的做法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
<argLine>--add-opens java.base/java.util=ALL-UNNAMED</argLine>
<argLine>--add-opens java.base/java.io=ALL-UNNAMED</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我仍然遇到同样的问题:(有什么帮助吗?
小智 7
对我来说,它只是将参数合并在一个声明中:
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
Run Code Online (Sandbox Code Playgroud)