用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. Android培训准备资料之UI一些相似控件和控件一些相似属性之间的区别

    这一篇博客主要收集五大布局中的一些相似控件和控件一些相似属性之间的区别 ImageView ImageButton Button 三者有啥区别? (1)Button继承自TextView,ImageV ...

  2. Jsp调用淘宝IP地址库获取来访IP详细信息

    Jsp调用淘宝IP地址库获取来访IP详细信息   示例网页点击:www.trembler.cn/ipinfo/ipinfo(服务器有其他用处,页面已失效) String ip = request.ge ...

  3. python学习3-python views.py的返回值

    2.首先要说明一点是,对于HttpRequest对象来说,是Django自己创建的,但是HttpResponse就必须要我们自己创建.注意每个view方法都必须返回一个HttpResponse对象,H ...

  4. [linux] shell脚本编程-统计日志文件中的设备号发通知邮件

    1.日志文件列表 比如:/data1/logs/2019/08/15/ 10.1.1.1.log.gz 10.1.1.2.log.gz 2.统计日志中的某关键字shell脚本 zcat *.gz|gr ...

  5. [TCP/IP] TCP报文长度是由什么确定的

    MTU:最大传输单元,以太网的MTU为1500Bytes MSS:最大分解大小,为每次TCP数据包每次传输的最大数据的分段大小,由发送端通知接收端,发送大于MTU就会被分片 TCP最小数据长度为146 ...

  6. 1-11Set结构

    集合 只保留下来唯一的元素 tang=[123,123,456,789,] tang=set(tang) tang {123, 456, 789} tang=set() type(tang) set ...

  7. 常用linux系统监视软件

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo ##epel源 yum install -y ...

  8. Eyoo大学生交友平台

    团队简介 团队名称 golden express 队员学号列表 王伟 201731062214 刘冬 201731062227 张旭 201731062129 秦裕航 201731062432 (组长 ...

  9. mysql的floor()报错注入方法详细分析

    刚开始学习sql注入,遇见了 select count(*) from table group by floor(rand(0)*2); 这么条语句.在此做个总结. (更好的阅读体验可访问 这里 ) ...

  10. Tools分类随笔链接整理贴(不定期更新)

    1.编程开发工具 Vs2012安装介绍   https://www.cnblogs.com/fzxiaoyi/p/12041854.html Vs2012帮助文档安装介绍  https://www.c ...