引自: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>