jenkins运行报错:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project lego

起因:我要对4000条数据循环请求搜索接口,校验返回值,然后在Jenkins上面运行的时候报错:maven-surefire-plugin执行test失败,但是运行70条数据的时候就不会报错,而且程序本身也没有错误,猜测应该是数据量大导致的。通过查阅网上的资料说是要设置surefire插件的jvm 参数。

Jenkins运行报下面的错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project lego: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?


解决方法:

在pom文件中的maven-surefire-plugin插件标签里面增加下面一行:

<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>完整如下:
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <forkMode>once</forkMode>
                    <argLine>-Dfile.encoding=UTF-8 -Xmx1024m -XX:MaxPermSize=256m</argLine>
                    <suiteXmlFiles>
                        <suiteXmlFile>${resource.dir}${case}/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <testFailureIgnore>true</testFailureIgnore>
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>true</value>
                        </property>
                    </properties>
                    <reportsDirectory>target/surefire-reports</reportsDirectory>
                </configuration>
            </plugin>

  

Maven运行测试用例时,是通过调用maven的surefire插件并fork一个子进程来执行用例的,

使用argLine属性,可以指定额外的参数传递给forked的jvm进程,例如内存设置

JVM 参数:

-Xmx1024m  jvm最大允许分配的堆内存,按需分配

-XX:MaxPermSize=256m  jvm最大允许分配的非堆内存,按需分配

java的内存管理机制:

堆(heap)和非堆(non-heap):

堆是运行时数据区域,所有类实例和数组的内存均从此处分配。堆是在java虚拟机启动时创建的。在jvm堆之外的内存称为非堆内存

堆是java代码可用的内存,是留给开发人员使用的,非堆是jvm留给自己用的,

堆内存分配

JVM初始分配的堆内存由-Xms指定,默认是物理内存的1/64;JVM最大分配的堆内存由-Xmx指定,默认是物理内存的1/4。默认空余堆内存小于40%时,JVM就会增大堆直到-Xmx的最大限制;
 空余堆内存大于70%时,JVM会减少堆直到-Xms的最小限制。因此服务器一般设置-Xms、-Xmx 相等以避免在每次GC 后调整堆的大小。
 说明:如果-Xmx 不指定或者指定偏小,应用可能会导致java.lang.OutOfMemory错误,此错误来自JVM,不是Throwable的,无法用try...catch捕捉。

非堆内存分配

JVM使用-XX:PermSize设置非堆内存初始值,默认是物理内存的1/64;由XX:MaxPermSize设置最大非堆内存的大小,默认是物理内存的1/4。

时间: 2024-10-06 15:28:41

jenkins运行报错:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project lego的相关文章

mvn install 报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2 错误: 找不到符号

报错信息 在Eclipse中执行mvn install时,console端显示如下报错信息: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ERP: Compilation failure: Compilation failure: [ERROR] \test01\src\main\java\HStyl

SpringBoot MAVEN编译报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:

参考了好几篇文章没搞定,直到查询错误关键字 An unknown compilation problem occurred 分别参考了以下博客: https://blog.csdn.net/fanrenxiang/article/details/80864908 https://blog.csdn.net/weixin_42167717/article/details/80377123 最后搞定的是这篇 https://my.oschina.net/u/170632/blog/857078 An

IDEA报错Failed to execute goal

debug后报错:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) 在ponm.xml中加入如下配置:<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-pl

maven install时报错 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test)

今天在一个maven项目上执行maven install命令的时候一直报错,错误信息如下: [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.16

maven 编译出错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean

eclipse在使用maven的tomcat控件编译java程序时,报错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project **-web: Failed to clean project: Failed to delete E:\**\target\tomcat\logs\access_log 这类错误 出现这种错误,通常是由于您已启动了另

maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang

maven打包成war时,报错:Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang: Error assembling WAR: webxml attribute is required 原因:找不到web.xml,但是项目中明明有这个文件,在WebContent/WEB-INF/文件夹下,就是识别不了解决方法:需要在pom

解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project autotest_fchtgl: Compilation failure的方法

在碰到maven install 发现报错 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project autotest_fchtgl: Compilation failure [ERROR] No compiler is provided in this environment. Perhaps you are running on

针对maven install 报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1 解决方案

项目运行环境:jdk1.8+tomcat8 maven install 时报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1 造成此错误的原因也比较多,下面分2种情况: 情况1(常见):你可能编译在一个JRE而不是JDK上,maven 编译是要JDK的,即你的编译器配置了一个jre路径,需要换成jdk. 操作:window→preference→java→Installed JREs 点add添

git 打包报错:Maven Build时提示:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test

1.使用git 升级 服务命令 mvn  deploy -e 之后报错: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project zm-live-client: Unable to generate classpath: org.apache.maven.artifact.resolver.ArtifactResolutionExcept