maven打包时会把该包依赖的包一起打进来,但某些时候我们并不需要这些包,例如xerces(用于解析XML)导进来后可能会造成tomcat启动的异常(包冲突),需要打包时排除掉。
1、排除依赖包
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.1</version>
<exclusions>
<exclusion>
<artifactId>xercesImpl</artifactId>
<groupId>xerces</groupId>
</exclusion>
</exclusions>
</dependency>
2、过滤文件
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<!-- 包含 -->
<includes>
<include>**/*.vm</include>
<include>**/*.properties</include>
</includes>
<!-- 排除 -->
<excludes>
<exclude>**/*.log</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/*.log</exclude>
</excludes>
</resource>
</resources>
</build>