运行mvn clean verify -P P1
时,我得到这个奇怪的堆栈跟踪
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.21.0:verify (default) on project prj-name: There are test failures.
[ERROR]
[ERROR] Please refer to C:\path\to\project\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] sun.reflect.annotation.TypeNotPresentExceptionProxy
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:658)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
这是什么意思?
maven pom. xml文件:
<profiles>
<profile>
<id>P1</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<!-- Includes integration tests -->
<includes>
<include>**/integration/*.java</include>
<include>**/integration/*/*.java</include>
</includes>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
- 更新**
有个万无一失的转储文件
ForkStarter IOException: For input string: "1;5".
org.apache.maven.plugin.surefire.booterclient.output.MultipleFailureException: For input string: "1;5"
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.<init>(ThreadedStreamConsumer.java:58)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.<init>(ThreadedStreamConsumer.java:110)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:596)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:854)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:200)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:196)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
由于字符串变量中的垃圾和日志中偶尔出现的IndexOutOfBoundsException
/ConcurrentModificationException
,这似乎是一个并发问题。
5条答案
按热度按时间hts6caw31#
我遵循了这里提出的解决方案:https://github.com/spring-projects/spring-boot/issues/6254#issuecomment-307151464
目前,我有故障保护插件2.22.0,我可以使用这个版本,并通过显式配置
classesDirectory
属性不降级:示例:
另一种变通方案将在后面的Github问题线程中描述:https://github.com/spring-projects/spring-boot/issues/6254#issuecomment-343470070
备注(2020年2月27日):
maven-failsafe-plugin
版本3.0.0-M4仍然需要以下变通方法:-(u3r8eeie2#
我的测试类有LoginPageTest.java,我删除了.java,工作得很好。:)
zbdgwd5y3#
我曾经得到的问题,主要是问题是初始化示例变量。检查您的示例变量是工作在本地,如果工作检查当他们运行在CI/CD管道。
olhwl3o24#
另一种解决方法是为重新打包的jar配置一个分类器,这允许Failsafe使用原来的jar:
这个问题是由于Failsafe插件的变化和 Boot 1.4中重新打包的jar文件布局的变化共同造成的。从Failsafe 2.19开始,
target/classes
不再出现在类路径上,而是使用项目的内置jar。对于Boot应用程序,这是重新打包的jar。在1.4中,应用程序的类从jar的根目录移动到BOOT-INF/classes
目录。这阻止了它们被Failsafe加载。源代码:GitHub问题
evrscar25#
这个GitHub问题-[#6254] Maven-failsafe-plugin fails to execute integration tests-和相关的讨论帮助我解决了我的问题。
这是一个bug。事实证明更新的Failsafe插件版本(2.19.0及更高版本)在Sping Boot 1.4(或更高版本)上不能很好地工作。解决方法是将maven-failsafe-plugin降级到2.18.1。以下是更新的pom.xml: