请帮我解决这个问题。我不太明白日志中的错误是什么意思。

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.749s
[INFO] Finished at: Thu Apr 24 10:10:20 IST 2014
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project samples.simpleforwarding: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0_55\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefirebooter53410321571238933.jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire86076271125218001tmp E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire_01846991116135903536tmp"
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

当前回答

我也经历过这种情况-但在我的情况下,我为黄瓜编写了一个自定义钩子

public class MappingFormatter implements gherkin.formatter.Formatter {

...

我的方法之一是产生一个空指针异常,这导致surefire退出而不记录错误。

其他回答

我有这么多时间,对我来说,这几乎总是与“控制台”有关,与实际的分叉无关。

总之,我的解决方案是:

添加-B(批处理模式) 添加JVM参数-Djansi。力= true -Djansi.passthrough = true

在一个给定的项目中,这将在一个新的windows控制台系统失败(cmd.exe)

[path_to_jdk] \ java.exe -Dmaven.home=[path_to_maven]\apache-maven-3.6.3 -Dclassworlds.conf=[path_to_maven]\bin. \bin\m2.conf -Dmaven.home=[path_to_maven]multiModuleProjectDirectory = path_to_myproject -Dfile。utf - 8编码= -Djansi。力= true -Djansi。passthrough=true -classpath [path_to_maven]\boot\plexus-classworlds-2.6.0.jar org.codehaus.plexus.classworlds.launcher.Launcher清洁安装

这将始终在一个新的控制台窗口(cmd.exe)中工作。

[path_to_jdk] \ java.exe -Dmaven.home=[path_to_maven]\apache-maven-3.6.3 -Dclassworlds.conf=[path_to_maven]\bin. \bin\m2.conf -Dmaven.home=[path_to_maven]multiModuleProjectDirectory = path_to_myproject -Dfile。utf - 8编码= -Djansi。力= true -Djansi。passthrough=true -classpath [path_to_maven]\boot\plexus-classworlds-2.6.0.jar org.codehaus.plexus.classworlds.launcher.Launcher清洁安装

注意,这两个命令都有-B(批处理模式,应该关闭着色),唯一的区别是

-Djansi.force=true -Djansi.passthrough=true

现在我只需要能够将这些“JVM参数”传递给“mvn”。Cmd”以使其更好。

我猜是这样的:有没有一种方法通过命令行将jvm参数传递给maven?


一点背景知识:

从maven (3. exe)的最新版本开始,我就反复遇到这个问题。x +)。 我尝试过这里的许多解决方案,有时运气好,有时不好。

这篇来自官方文档的文章一直都没用:https://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html

但有一些常数,当我处理这个问题时

总是在窗口,本地 总是有大量的控制台输出。 并不是所有的团队开发人员都会在特定项目中犯错误 Jenkins的构建会通过 IT测试中的大量控制台输出(故障安全集成测试)

关键的发现是,我注意到在Eclipse中(有或没有嵌入式maven版本),完整的maven构建(干净安装)都可以工作。

因此,我弄清楚了Eclipse使用的是哪个命令(谢谢:我如何获得Eclipse运行配置的命令行?)

从那里,我可以确定解是什么。

看看人们说的其他答案

输出到日志文件 降低日志级别 https://stackoverflow.com/a/52033799/1634131 https://stackoverflow.com/a/64132709/1634131 等

这里显然有一个bug。或者在Maven中,或者在windows控制台中,或者在Jansi库中,或者在这些组件的集成中。

在我的情况下,通过设置MAVEN_OPTS增加内存有助于:

set MAVEN_OPTS=-Xmx1024m

最近travis终止了一个测试的执行(没有改变任何相关的东西(以及在开发人员机器上成功的构建!)),因此BUILD FAILURE。 原因之一是这样的(见@agudian的答案):

Surefire不支持调用System.exit()的测试或任何引用库

(因为测试类确实称为System.exit(-1))。

相反,使用简单的return语句会有所帮助。 为了让travis再次开心,我还必须添加@xiaohuo提供的surefire参数(<argLine>)。(此外,我必须删除-XX:MaxPermSize=256m,以便能够在我的一个台式机上构建)

只做这两件事中的一件是行不通的。

要了解更多背景知识,请阅读何时调用系统。退出Java。

我的决心是将Jenkinsfile中提到的超时时间从90更改为120。

pipeline {
    agent { label projectName }

options {
    disableConcurrentBuilds()
    buildDiscarder(logRotator(numToKeepStr:'5'))
    timeout(time: 90, unit: 'MINUTES')
}

谢谢 南非

测试中使用的分叉JVM内存不足。 解决方案是禁用分叉JVM并在主JVM上运行测试,以确保有足够的内存,或者通过参数来增加分叉JVM的内存

在这个答案中找出答案