<useSystemClassLoader>false</useSystemClassLoader>

在Jenkins上执行接口测试时遇到错误,如VM终止未正常告别,可能由System.exit调用引起。通过在pom.xml中配置maven-surefire-plugin插件,设置useSystemClassLoader为false,forkMode为once,解决Jenkins测试任务失败问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jenkins上运行接口测试用例报错:

Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project apitest: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/jenkins/workspace/dht-ceshi112 && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Dfile.encoding=UTF-8 -jar /home/jenkins/workspace/dht-ceshi112/target/surefire/surefirebooter2365510698734909951.jar /home/jenkins/workspace/dht-ceshi112/target/surefire/surefire2899246126287720087tmp /home/jenkins/workspace/dht-ceshi112/target/surefire/surefire_07248019886580183342tmp
[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

修改方法:pom.xml中增加<useSystemClassLoader>false</useSystemClassLoader>解决,设置maven使用独立的类加载器
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFiles}</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>

转载于:https://www.cnblogs.com/zjxyz2008zhangjuan/p/9944933.html

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>io.renren</groupId> <artifactId>renren-security</artifactId> <version>4.0.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>renren-api</artifactId> <packaging>jar</packaging> <description>renren-api</description> <dependencies> <dependency> <groupId>io.renren</groupId> <artifactId>renren-common</artifactId> <version>4.0.0</version> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- 跳过单元测试 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.4.14</version> <configuration> <imageName>renren/api</imageName> <dockerDirectory>${project.basedir}</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> <!-- 运行命令 mvn clean package docker:build 打包并生成docker镜像 --> </plugin> </plugins> </build> </project> 这是完整的pom文件 请帮我修改一下
06-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值