Java Maven surefire和JDK 11
我试图让Maven surefire在JDK 11下运行,但我一直遇到以下错误:Java Maven surefire和JDK 11,java,maven,testing,maven-surefire-plugin,java-11,Java,Maven,Testing,Maven Surefire Plugin,Java 11,我试图让Maven surefire在JDK 11下运行,但我一直遇到以下错误: 如果我将reuseForks设置为true: 如果我将其设置为false: 我发现和链接描述了相同的问题,但它们没有任何解决方案 为了复制我创建的这个bug似乎是在使用模块化项目进行测试时,您需要将forkCount设置为0: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId&g
reuseForks
设置为true:为了复制我创建的这个bug似乎是在使用模块化项目进行
测试时,您需要将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>
我在这里找到了解决方案:
我必须补充一点
<argLine>
--illegal-access=permit
</argLine>
--非法进入=许可证
org.apache.maven.plugins
maven surefire插件
2.22.0
--非法进入=许可证
org.apache.maven.plugins
maven故障保护插件
2.22.0
--非法进入=许可证
您是否尝试过较旧版本的surefire插件,例如2.21.0?@gjoranv是的,我在2.21.0上遇到了相同的问题由于某种原因,模块信息
类正在干扰测试。我已经移除了它,测试工作正常。可能插件还没有为模块化项目做好准备?模块本身也有问题(可能是因为错误的openjfx monocle依赖关系)。虽然我认为这会导致测试使用类路径而不是模块路径运行。所以这意味着并行maven执行是不可能的?因为-T1C
和forkCount
0无法组合。Found修复了多线程问题。@Dormouse,如何实现post中的建议来解决多线程问题?我没有看到任何关于线程的引用。正是--非法访问=permit
,Cesar雄辩地变成了一个线程,我似乎太懒了。这在spring boot项目中对我不起作用。我不得不说是2点21分。不知道为什么。否则,我会得到一个编译错误:关于反射api的一些东西。
<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>
# 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)
<argLine>
--illegal-access=permit
</argLine>
<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>