首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven surefire和JDK 11

Maven surefire和JDK 11
EN

Stack Overflow用户
提问于 2018-11-22 20:48:25
回答 2查看 18.9K关注 0票数 11

我试图让Maven surefire在JDK 11下运行,但我一直得到以下错误:

  1. 如果我将reuseForks设置为true:

启动叉发生错误,请检查日志进程退出代码中的输出:1在org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:670) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)

  1. 如果我把它设为假的话:

执行默认-目标的测试org.apache.maven.plugins:maven-surefire- plugin:3.0.0-m1:测试失败: org.apache.maven.plugin.surefire.StartupReportConfiguration : java.lang.ClassNotFoundException:

我发现了描述相同问题的链接,但它们没有任何解决方案。

为了复制这个bug,我创建了这个git回购

EN

回答 2

Stack Overflow用户

发布于 2018-11-23 03:41:22

在对test使用模块化项目时,需要将forkCount设置为0

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M1</version>
    <configuration>
        <forkCount>0</forkCount> <!-- changed this to 0 -->
        <reuseForks>false</reuseForks>
        <!-- <threadCount>1</threadCount> --> <!-- shall be used with 'parallel' -->
        <printSummary>true</printSummary>
        <!-- <skipTests>false</skipTests> --> <!-- defaults to false -->

        <!-- run test in headless mode -->
        <systemPropertyVariables>
            <glass.platform>Monocle</glass.platform>
            <monocle.platform>Headless</monocle.platform>
            <prism.order>d3d</prism.order>
        </systemPropertyVariables>

        <argLine>
            --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
            --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
        </argLine>
    </configuration>
</plugin>

引用从本文中

module-info.java出现并启用了fork进程时,将使用模块和未命名模块创建混合类路径,从而导致模块可见性问题,并阻止应用程序启动。

备注:禁用forkCountreuseForks配置参数,导致引发org.apache.maven.surefire.booter.SurefireBooterForkException,类似于万里火-1528中报告的配置参数。

如果这可以帮助Maven社区的开发人员,相同运行中的执行转储会读取以下内容:

代码语言:javascript
复制
# Created at 2018-11-23T09:31:53.631
Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'Error occurred during initialization of boot layer'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'Error occurred during initialization of boot layer'.
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
    at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
    at java.base/java.lang.Thread.run(Thread.java:834)

下面是源代码存储库中的代码行。

票数 15
EN

Stack Overflow用户

发布于 2019-10-31 20:50:59

我在这里找到了解决办法:

https://winterbe.com/posts/2018/08/29/migrate-maven-projects-to-java-11-jigsaw/

我不得不补充一下。

代码语言:javascript
复制
<argLine>
    --illegal-access=permit
</argLine>
代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <argLine>
            --illegal-access=permit
        </argLine>
    </configuration>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <argLine>
            --illegal-access=permit
        </argLine>
    </configuration>
</plugin>
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53437819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档