Gna*_*nas 6 java testing maven maven-surefire-plugin java-11
我试图让Maven确定在JDK 11下运行,但我不断收到这些错误:
reuseForks为true:Run Code Online (Sandbox Code Playgroud)Error occurred in starting fork, check output in log Process Exit Code: 1 at 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)
Run Code Online (Sandbox Code Playgroud)Execution default-test of goal org.apache.maven.plugins:maven-surefire- plugin:3.0.0-M1:test failed: java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.StartupReportConfiguration
我发现这个和这个链接描述了同样的问题,但他们没有任何解决方案.
为了复制这个bug,我创建了这个git repo
Nam*_*man 11
似乎在使用模块化项目时test,您需要forkCount设置为0:
<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>
Run Code Online (Sandbox Code Playgroud)
引用本文
如果
module-info.java存在且fork进程已启用,则surefire会创建一个包含模块和未命名模块的混合类路径,从而导致模块可见性问题并阻止应用程序启动.
注意:禁用forkCount和reuseForks配置参数会导致org.apache.maven.surefire.booter.SurefireBooterForkException抛出,类似于 SUREFIRE-1528中报告的那样.
如果这可以帮助Maven社区的开发人员,则来自同一运行的执行转储将显示以下内容:
# 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)
Run Code Online (Sandbox Code Playgroud)
小智 6
我在这里找到了解决方案:
https://winterbe.com/posts/2018/08/29/migrate-maven-projects-to-java-11-jigsaw/
我不得不补充。
<argLine>
--illegal-access=permit
</argLine>
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3550 次 |
| 最近记录: |