引入:http://blog.csdn.net/sanzhongguren/article/details/71191290

在spring reference中提到一个解决spring jar包之间版本冲突的解决方案,原文如下

It is possible to accidentally mix different versions of Spring JARs when using Maven. For example, you may find that a third-party library, or another Spring project, pulls in a transitive dependency to an older release. If you forget to explicitly declare a direct dependency yourself, all sorts of unexpected issues can arise.

To overcome such problems Maven supports the concept of a "bill of materials" (BOM) dependency. You can import the spring-framework-bom in yourdependencyManagement section to ensure that all spring dependencies (both direct and transitive) are at the same version.

在配置spring项目依赖时可以通过引入spring-framework-bom避免项目中的spring jar包及关联依赖的三方jar包之间的版本冲突,引入方式:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.1.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

引入后的另一个好处就是在pom文件中引入spring相关依赖时不用再声明<version>属性,以后直接像下边这样声明就可以了:

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependencies>

PS: Spring官方reference网址 http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/
还有就是最近找到一个翻译reference的网址,虽然没有翻译完整有兴趣的也可以看看 http://spring.cndocs.tk/

spring maven项目解决依赖jar包版本冲突方案的更多相关文章

  1. eclipse导入maven项目后依赖jar包更新问题->update project按钮

    eclipse导入maven项目后依赖jar包更新问题 1.eclipse有专门的导入maven项目按钮,file-import-maven project,eclipse会自动查找指定路径下的pom ...

  2. maven项目导入依赖jar包并打包为可运行的jar包

    1.在pom.xml文件中添加插件 <build> <finalName>LeadServer</finalName> <!-- jar包名前缀,如果没有指定 ...

  3. maven项目搜索依赖jar包顺序

    local_repo  >  settings_profile_repo  >  pom_profile_repo  >  pom_repositories  >  setti ...

  4. spring data redis的使用jar包版本冲突问题

    spring data redis 与spring 版本之间会有不兼容,要求spring 最低版本为4.2.6,这里推荐的一个版本 spring 4.3.2  spring data redis 1. ...

  5. Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图(转载)

    Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图 2017年04月05日 10:53:13 李学凯 阅读数:104997更多 所属专栏: Intellij Idea   ...

  6. Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图

    Maven 组件界面介绍 如上图标注 1 所示,为常用的 Maven 工具栏,其中最常用的有: 第一个按钮:Reimport All Maven Projects 表示根据 pom.xml 重新载入项 ...

  7. eclipse maven 项目导出为 jar 包

    一个 maven 项目有很多依赖,所以最后打出的 jar 一般会很多,且比较大,打成 jar 包的步骤 (注意pom.xml文件中打包类型不能是war包): 1. 把 pom.xml 中依赖的库打成 ...

  8. maven无法下载依赖jar包—几种仓库的区别

    一.问题背景 最近这两天,感觉自己智商急剧退化,到了自己都捉急的地步,呃,有必要记录下来,以后智商被人甩几条街的时候,看看这篇文字,找找灵感也是好的! 这个项目呢,是用IDEA开发的,我一切都弄好了, ...

  9. maven项目引用外部jar包的方法

    问题描述: 有一个java maven web项目,需要引入一个第三方包gdal.jar,但是这个包是自己打包的,在maven中央库里面找不到该包,因此我采用传统的方式,将这个包拷贝到:项目名称\sr ...

随机推荐

  1. 页面提交 string数组和list对象集合举例

    ajax表单提交   $.ajax({                 cache: true,                 type: "POST",             ...

  2. springmvc+mybatis+redis实现查询插入操作

    最近在学习redis,虽然现在还不是很熟练.不过可以进行简单的框架整合开发. IDE:我使用的是IDEA.springmvc+spring+mybatis的整合这个我就不多说了,下面我们先进行这块的整 ...

  3. Java 输出文件通过 BufferedWriter.newline() 方法换行

    最近项目中需要导出文件,其实导出文件是一个挺简单的事情.但是却遇到了很奇怪的问题. 首先导出到文件需要用到 BufferedWriter.而换行则是通过 bw.newline() 方法,问题将出在 n ...

  4. pat甲级 1154 Vertex Coloring (25 分)

    A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices ...

  5. RF第二讲--Selenium2Library库的简单实用

    现在对于RF的应用方法已经有很多书介绍了,网上也可以搜到免费的电子书可以学习.今天就简单和大家介绍一下RF的用法之一,就是基于Selenium2Library库的使用. 1.首先需要安装Seleniu ...

  6. elixir 集成ejabberd

    备注: 我开发测试的环境时centos 1. 预备环境 1. openssl yum install -y  openssl-devel 2. xml yum install -y expat-dev ...

  7. 【Oracle】OGG单向复制配置

    实验环境: 源端: Ip:192.168.40.10 DataBase:Oracle 11.2.0.1.0 ORCL OS:OEL5.6 OGG:fbo_ggs_Linux_x86_ora11g_32 ...

  8. OpenVPN 部署

    https://blog.frognew.com/2017/09/installing-openvpn.html#21-%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96 为了方 ...

  9. zabbix 布署实践【8 监控windows server】

    参考http://www.cnblogs.com/likehua/p/3968689.html的思路,我安装的是zabbix 3.0 从zabbix官网下载windown的 Zabbix pre-co ...

  10. Python nltk English Detection

    http://blog.alejandronolla.com/2013/05/15/detecting-text-language-with-python-and-nltk/ >>> ...