table of Contents
Preface
There are many ways to skip test test classes when maven compiles and packs. Here are several common ways
1. MAVEN command
You can use the following commands
mvn install -Dmaven.test.skip=true
或者
#=true可以省略,DskipTests属性默认为true
mvn install -DskipTests=true
the difference:
mvn install -Dmaven.test.skip=true test classes will not generate .class files
mvn install -DskipTests test classes will generate .class files
2. POM file
The spring boot project skips the test and uses spring-boot-maven-plugin, which needs to be added in pom.xml:
<properties>
<skipTests>true</skipTests>
</properties>
Example:
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
3、idea
If we are installing or package compiling the project in idea, then click the small icon below, idea will help us add -DskipTests=true when compiling, skip the test class