详解 maven的pom.xml用解决版本问题
时间:2020-12-26 12:29:41|栏目:JAVA代码|点击: 次
详解 maven的pom.xml用<exclusion>解决版本问题
用maven管理库依赖,有个好处就是连同库的依赖的全部jar文件一起下载,免去手工添加的麻烦,但同时也带来了同一个jar会被下载了不同版本的问题,好在pom的配置里面允许用<exclusion>来排除一些不需要同时下载的依赖jar 。
比如配置struts-core,它会同时下载javassist和asm相关的jar,但版本又不够新,这时可以排除它们:
<!-- Struts2 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
<exclusions>
<exclusion>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>asm</groupId>
<artifactId>asm-commons</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
如有疑问请留言或者到本站社区交流讨论,希望通过本文能帮助到大家,谢谢大家对本站的支持!


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




