How to exclude jars generated by maven war plugin
2016-01-14 23:47
309 查看
Because of transitive dependencies, my wars are getting populated by xml-apis, xerces jars. I tried following the instructions on the reference page for maven-war-plugin but it is not working.
What am I doing wrong ? If it matters, I discovered that the maven-war-plugin I'm using is at version 2.1-alpha-1
You can mark these dependencies as provided:
This way the maven will add them to the compilation classpath, but will not package them. It is assumed they exist in your servlet container.
See more about maven scopes here under "scope"
Edit If you want to remove classes added via transitive dependencies you can exclude them from the dependency like this:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <packagingExcludes>WEB-INF/lib/xalan-2.6.0.jar,WEB-INF/lib/xercesImpl-2.6.2.jar,WEB-INF/lib/xml-apis-1.0.b2.jar,WEB-INF/lib/xmlParserAPIs-2.6.2.jar</packagingExcludes> <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml> <warName>project1</warName> <warSourceDirectory>src/main/webapp</warSourceDirectory> </configuration> </plugin>
What am I doing wrong ? If it matters, I discovered that the maven-war-plugin I'm using is at version 2.1-alpha-1
You can mark these dependencies as provided:
<dependency> <groupId>xerces</groupId> <artifactId>xerces</artifactId> <version>2.4.0</version> <scope>provided</scope> </dependency>
This way the maven will add them to the compilation classpath, but will not package them. It is assumed they exist in your servlet container.
See more about maven scopes here under "scope"
Edit If you want to remove classes added via transitive dependencies you can exclude them from the dependency like this:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.6</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency>
相关文章推荐
- maven学习
- maven插件maven-war-plugin的使用
- jenkins------部署项目到jboss eap下
- maven使用经验集
- window下安装和配置maven环境
- 使用maven+eclipse搭建struts2开发环境
- Java随手笔记8之包、环境变量和访问控制及maven profile实现多环境打包
- maven中下载jar包源码和javadoc的命令介绍
- 表单重复提交处理总结
- Maven私服配置记录 Nexus
- Maven学习笔记
- Maven实战(三)Eclipse构建Maven项目
- maven基本要点
- Maven for Eclipse
- maven 使用 问题记录
- 《Maven权威指南》学习笔记四_创建一个简单的Maven项目
- 《Maven权威指南》学习笔记十七_一个多模块项目 3ff0
- 《Maven权威指南》学习笔记十八_多模块企业级项目 3ff0
- 《Maven权威指南》学习笔记二十_关于POM
- 近日maven学习概况