用maven管理库依赖,有个好处就是连同库的依赖的全部jar文件一起下载,免去手工添加的麻烦,但同时也带来了同一个jar会被下载了不同版本的问题,好在pom的配置里面允许用<exclusion>来排除一些不需要同时下载的依赖jar 。

比如配置struts-core,它会同时下载javassist和asm相关的jar,但版本又不够新,这时可以排除它们:

  1. <!-- Struts2 -->
  2. <dependency>
  3. <groupId>org.apache.struts</groupId>
  4. <artifactId>struts2-core</artifactId>
  5. <version>${struts.version}</version>
  6. <exclusions>
  7. <exclusion>
  8. <groupId>javassist</groupId>
  9. <artifactId>javassist</artifactId>
  10. </exclusion>
  11. <exclusion> <!-- we prefer our explicit version, though it should be the same -->
  12. <groupId>asm</groupId>
  13. <artifactId>asm</artifactId>
  14. </exclusion>
  15. <exclusion> <!-- we prefer our explicit version, though it should be the same -->
  16. <groupId>asm</groupId>
  17. <artifactId>asm-commons</artifactId>
  18. </exclusion>
  19. <exclusion> <!-- we prefer our explicit version, though it should be the same -->
  20. <groupId>org.ow2.asm</groupId>
  21. <artifactId>asm</artifactId>
  22. </exclusion>
  23. <exclusion> <!-- we prefer our explicit version, though it should be the same -->
  24. <groupId>org.ow2.asm</groupId>
  25. <artifactId>asm-commons</artifactId>
  26. </exclusion>
  27. </exclusions>
  28. </dependency>
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rocklee/article/details/51692054

maven的pom.xml用<exclusion>解决版本问题的更多相关文章

  1. maven 通过 pom.xml 指定java编译版本

    <!-- 给maven项目指定编译版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> ...

  2. 【IDEA】IDEA中maven项目pom.xml依赖不生效解决

    问题: 今天在web项目中需要引入poi相关jar包.查看之下才发现pom.xml中的依赖虽然已经下载到了本地仓库 repository,但是却没有加入到项目路径的 Extenal Libraries ...

  3. idea中pom.xml没有工作 IDEA中maven项目pom.xml依赖不生效解决

    问题: 今天在web项目中需要引入poi相关jar包.查看之下才发现pom.xml中的依赖虽然已经下载到了本地仓库 repository,但是却没有加入到项目路径的 Extenal Libraries ...

  4. Idea项目:Failed to create a Maven project ‘…pom.xml’ already exists in VFS 解决

    在IDEA里面创建Module,因为项目类型原因删掉,又重新创建一个新的,名字没有变.于是报错: Failed to create a Maven project: '**/***/pom.xml' ...

  5. maven(4)------maven核心pom.xml文件常用元素分析

    在maven项目中,pom文件是核心文件 pom.xml: <?xml version="1.0" encoding="UTF-8"?> <p ...

  6. 史上最全的maven的pom.xml文件详解(转载)

    此文出处:史上最全的maven的pom.xml文件详解——阿豪聊干货 <project xmlns="http://maven.apache.org/POM/4.0.0" x ...

  7. Maven项目pom.xml配置详解

    maven项目pom.xml文件配置详解,需要时可以用作参考: <project xmlns="http://maven.apache.org/POM/4.0.0" xmln ...

  8. maven的pom.xml详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. (六)Maven之pom.xml文件简单说明

    通过前面几部分知识,我们对maven已经有了初步的印象,就像Make的Makefile.Ant的build.xml一样,Maven项目的核心是pom.xml.POM(Project Object Mo ...

随机推荐

  1. ios-tableview加载卡顿的解决方案

    参考文章:http://www.cocoachina.com/articles/11968 总结: 提前计算并缓存好高度(布局),因为heightForRowAtIndexPath:是调用最频繁的方法 ...

  2. Vue+ElementUI 安装与应用

    1.初始化创建一个vue项目: 打开终端输入命令 vue init webpack vueui ---------------------------------- ? Project name my ...

  3. PostgreSQL limit

    1. select * from my_table limit 10 offset 5 数据是从第0条开始的,所以这句代码表示从 第六条数据开始的10行数据. 2. select * from my_ ...

  4. 《高性能 Go 代码工坊》中译

    深入研究 Go 应用性能提升的英语系列文章,这里是中译 https://www.yuque.com/ksco/uiondt

  5. 使用IDEA创建Maven项目和Maven使用入门(配图详解)

    本文详解的讲解了使用IDEA创建Maven项目,及Maven的基础入门. 1.打开IDEA,右上角选择File->New->Project 2.如图中所示选择Maven(可按自己所需添加, ...

  6. centos7-cockpit

    yum install cockpit* -y systemctl start cockpit.service systemctl enable cockpit.service 修改默认端口9090 ...

  7. 微信小程序,知识点

    对于小程序的授权,只要用户授权一次,该授权关系就会记录在后台,除非删除小程序,或者用户在设置中关闭该授权. 官方文档: https://developers.weixin.qq.com/minipro ...

  8. WIN10安装64位JDK10.0.2详细完整教程(图文)

    1.下载JDK 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 1)如下图,点击红色箭头处: 2)如下图 ...

  9. 创建maven父子项目(九)

    一.父子-聚合项目 通过 maven 可以创建父子-聚合项目. 所谓的父子项目,即有一个父项目,有多个子项目.这些子项目,在业务逻辑上,都归纳在这个父项目下,并且一般来说,都会有重复的jar包共享.所 ...

  10. JDOJ 1065 打倒苏联修正主义

    JDOJ 1065 https://neooj.com/oldoj/problem.php?id=1065 题目描述 [”客观”背景]苏修是苏联修正主义的简称.从1956年到1966年的10年间,过去 ...