【发布时间】:2017-11-09 17:18:01
【问题描述】:
当我从 Eclipse(Neon.3,EE 版本)运行 maven 命令“mvn clean install”时 我得到了错误:
org.apache.maven.plugin.PluginExecutionException: 执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test 的默认测试失败:分叉的 VM 没有正确告别就终止了。虚拟机崩溃或调用 System.exit ?
Eclipse 安装使用 m2e-plugin(默认)和 Java 1.8.0_131。但我也尝试过一些早期版本,包括 1.7.x。
试图寻找解决此问题的方法并发现: The forked VM terminated without saying properly goodbye. VM crash or System.exit called
尝试在pom.xml中添加如下配置
<profiles>
<profile>
<id>normal_build_profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<!-- Tried with lots of different values, no change -->
<threadCount>3</threadCount>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
使用上面的配置,它在执行此命令时在 Eclipse 中冻结(来自日志)
[DEBUG] 分叉命令行:cmd.exe /X /C "C:\Java\jdk1.8.0_131\jre\bin\java -Xmx1024m -XX:MaxPermSize=256m -jar C:\workspace\miniTest\目标\surefire\surefirebooter2156530837851203141.jar C:\workspace\miniTest\target\surefire 2017-06-08T08-58-59_461-jvmRun1 surefire2401124720884095509tmp surefire_03952770368534211516tmp"
但是当我从命令行运行“mvn clean install”时,一切都很好。 Eclipse 配置为使用与命令行中使用的相同的 Maven 安装。 Maven 版本是 3.5.0。 (虽然这也发生在 3.3.3 版本中)
由于这似乎与运行测试有关,我应该注意我也有这些:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- 4.11 Does not require that hamcrest dependency -->
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
有没有人知道 Eclipse 发生了什么,因为这似乎与它有关?
从命令行构建相当不方便。
在 Eclipse 中运行单元测试没有Maven 没问题。
【问题讨论】:
标签: eclipse maven-surefire-plugin