环境:Springboot2.x,配置如下
1. 方式一
<maven.test.skip>true</maven.test.skip>跳过测试且不会生成class
<skipTests>true</skipTests>会跳过测试但是会生成测试class
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<!-- spring热部署 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<!--默认关掉单元测试 -->
<!-- <maven.test.skip>true</maven.test.skip> -->
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
2. 方式二(推荐使用)
<maven.test.skip>true</maven.test.skip>跳过测试且不会生成class
<skipTests>true</skipTests>会跳过测试但是会生成测试class
spring-boot-maven-plugin插件已经集成了maven-surefire-plugin插件,会自动运行 Junit test,因此停用自动单元测试,只需要调用<skipTests>true</skipTests>或者<maven.test.skip>true</maven.test.skip>即可
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<!-- spring热部署 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<!--默认关掉单元测试 -->
<!-- <maven.test.skip>true</maven.test.skip> -->
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/opensource/191482.html