【问题标题】:how to pass --add-opens JDK module configuration to maven test如何通过--add-opens JDK模块配置到maven测试
【发布时间】:2020-11-19 21:48:35
【问题描述】:

我正在将生产代码中的 java 版本从 java 8 升级到 java 11。

由于使用了flume、zookeeper等第三方库,我必须在application java start命令中添加以下JDK模块配置。

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED

添加此配置后,java应用程序启动正常。

但是当我使用mvn test 运行测试时,测试失败了。我已将以下配置添加到 maven-surefire-plugin 中,但仍然抛出错误。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M5</version>
    <configuration>
        <argLine>--illegal-access=permit</argLine>
        <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
        <argLine>--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED</argLine>
        <argLine>-Dillegal-access=permit</argLine>
    </configuration>
</plugin>

我认为我在 Maven 测试中没有正确传递参数。 知道我做错了什么以及如何解决这个问题吗?

【问题讨论】:

    标签: java maven java-9 maven-surefire-plugin java-module


    【解决方案1】:

    这是一个单身argLine,比如:

    <argLine>
        --add-exports org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED
        --add-exports org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED
    </argLine>
    

    【讨论】:

      猜你喜欢
      • 2012-12-13
      • 2012-11-17
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 2016-12-18
      • 1970-01-01
      • 1970-01-01
      • 2018-04-20
      相关资源
      最近更新 更多