Maven 打包时排除Src/Java包下的java文件
项目结构如下所示:
打包编译时,想去掉Test包下的所有测试类java文件,这时候可以在Pom.xml中添加
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding><!-- 字符集编码 -->
<excludes>
com/how2java/springboot/Test/*
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
然后可以maven clean 一下 项目,再install,就可以发现该Test 包下的java文件没有被编译到jar包中.