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

[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

当前回答

如果有人包含自定义argLine参数,则必须重新考虑,因为它很可能是内存分配问题的根源。

例如(我曾经有过):

<argLine>XX:MaxPermSize=4096m ${argLine}</argLine>

现在我使用硬指定值:

<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>

无论出于何种原因,与Surefire集成的应用程序(如Jacoco)不会请求足够的内存来与构建时发生的测试共存。

其他回答

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

set MAVEN_OPTS=-Xmx1024m

Surefire FAQ的这一部分可以帮助你:

Surefire fails with the message "The forked VM terminated without properly saying goodbye" Surefire does not support tests or any referenced libraries calling System.exit() at any time. If they do so, they are incompatible with surefire and you should probably file an issue with the library/vendor. Alternatively the forked VM could also crash for a number of reasons, which can also make this issue happen. Look for the classical "hs_err*" files indicating VM crashes or examine the log output from running maven when the tests execute. Some "extraordinary" output from crashing processes may be dumped to the console/log. If this happens on a CI environment and only after some time runs there is a fair chance your test suite is leaking some kind of OS-level resource that makes things worse for every run. Regular os-level monitoring tools may give you some indication.

可能是因为你在你的项目中应用了一些更改,没有更新他们所有的引用。

在我的情况下,我得到这个错误,因为我已经更新了包的名称在我的项目,但我忘记更新他们的引用在TestNG.xml文件。通过修正,我解决了这个错误。

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

总之,我的解决方案是:

添加-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库中,或者在这些组件的集成中。

简单的解决方案: 您应该添加src/test/resources/logback.xml

<configuration debug="false">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%date{HH:mm:ss.SSS} %highlight(%-5level)
            %gray(%logger{90}) %X{X-ApplicationId} %msg%n
        </pattern>
    </encoder>
</appender>