打包遇到错误Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test

引自:https://blog.csdn.net/xiexiangyan/article/details/107936774

遇到的问题

有一个maven项目,我clone一下最新的代码。准备打包(maven package),没想到在执行到TEST阶段报错。百思不得其解,决定跳过测试去打包,然后部署。

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project springboottest: There are test failures.

解决方式:在运行mvn install或mvn package时跳过Test。

方法1:在Terminal执行命令

mvn install -DskipTests

方法2:在Terminal执行命令

mvn install -Dmaven.test.skip=true

方法3:Spring boot项目使用

spring-boot-maven-plugin插件已经集成了maven-surefire-plugin插件,会自动运行 junit test

,只需要在pom.xml里增加如下配置:

<properties>
        <!-- 跳过测试 -->
    <skipTests>true</skipTests>
</properties>