在基於SpringBoot開發時有時只是為了build出Jar or War 但卻跑到測試,而測試又跟DB有關時,會造成很多困擾,所以可以使用<skipTests>true</skipTests>
跟<maven.test.skip>true</maven.test.skip>
跳過測試單元,可以使用以下方式
方法 1.
1 2 3 4 5 6 7 8 9 10 11 |
//pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud.version>Finchley.SR1</spring-cloud.version> <!--surefire plugin方式跳过maven test, 等同$ mvn package -DskipTests--> <skipTests>true</skipTests> <!--maven方式跳过maven test, 等同$ mvn package -Dmaven.test.skip=true--> <maven.test.skip>true</maven.test.skip> </properties> |
方法2.
1 2 3 4 5 6 7 8 |
// Plugin方式 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>false</skipTests> </configuration> </plugin> |
Reference
https://www.kagura.me/dev/20181017173540.html