如何将所有依赖关系升级到特定版本

问题描述:

我试着做一个mvn dependency:tree,我得到一个依赖关系树。如何将所有依赖关系升级到特定版本

我的问题是,我的项目取决于许多内部依赖于许多春天工件的模块。有几个版本冲突。我想升级所有春天相关的图书馆来说最新的(2.6.x或更高版本)。什么是这样做的首选方式?

我应该在我的pom.xml中声明所有deps spring-context,spring-support(和其他10个工件)并将它们指向2.6.x?还有其他更好的方法吗?

[INFO] +- com.xxxx:yyy-jar:jar:1.0-SNAPSHOT:compile 
[INFO] | +- com.xxxx:zzz-commons:jar:1.0-SNAPSHOT:compile 
[INFO] | | +- org.springframework:spring-dao:jar:2.0.7:compile 
[INFO] | | +- org.springframework:spring-jdbc:jar:2.0.7:compile 
[INFO] | | +- org.springframework:spring-web:jar:2.0.7:compile 
[INFO] | | +- org.springframework:spring-support:jar:2.0.7:compile 
[INFO] | | +- net.sf.ehcache:ehcache:jar:1.2:compile 
[INFO] | | +- commons-collections:commons-collections:jar:3.2:compile 
[INFO] | | +- aspectj:aspectjweaver:jar:1.5.3:compile 
[INFO] | | +- betex-commons:betex-commons:jar:5.5.1-2:compile 
[INFO] | | \- javax.servlet:servlet-api:jar:2.4:compile 
[INFO] | +- org.springframework:spring-beans:jar:2.0.7:compile 
[INFO] | +- org.springframework:spring-jmx:jar:2.0.7:compile 
[INFO] | +- org.springframework:spring-remoting:jar:2.0.7:compile 
[INFO] | +- org.apache.cxf:cxf-rt-core:jar:2.0.2-incubator:compile 
[INFO] | | +- org.apache.cxf:cxf-api:jar:2.0.2-incubator:compile 
[INFO] | | | +- org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.0-M1:compile 
[INFO] | | | +- org.codehaus.woodstox:wstx-asl:jar:3.2.1:compile 
[INFO] | | | +- org.apache.neethi:neethi:jar:2.0.2:compile 
[INFO] | | | \- org.apache.cxf:cxf-common-schemas:jar:2.0.2-incubator:compile 

UPDATE:我已删除多余的问题,关于“\ - ”所以我的问题是,现在什么主题询问:)

+0

如果您有两个单独的问题,请分两个单独的帖子!这两个问题似乎完全不相关(除了它们都是关于maven的事实之外)。 – 2010-04-07 09:04:43

+0

广告更新:通过简单地删除'\ -'部分,您可以有效地做出两个现有答案。这不是最好的方式。你可能*应该*将现在剩下的部分移到新的questiton中,并在这里留下原始问题。那么,你生活和学习。 – 2010-04-07 09:12:31

解决办法有两个:

  1. 的OSS方式:下载你所依赖的项目,它们迁移到最新版本Spring并给它们发送补丁,以便每个人都获得新功能

  2. 覆盖您自己的POM中每个依赖项的版本。

该子树的结束。没有什么比ASCII艺术的花哨一点 - 认为好像它的+ -

+0

我不认为这是真正的问题;-) – 2010-04-07 08:57:31

+0

Yuck :)那么是否有任何快捷方式将所有弹簧相关的工件升级到一个版本?我不想列出所有的10个春天,并指出它的版本。 – 2010-04-07 08:57:42

你看过dependecyManagement标签吗?它允许你指定父POM的每个依赖项的版本号。那么你的所有其他劲歌可以继承指定的版本:

<properties> 
    <spring.version>2.5.6</spring.version> 
</properties> 
... 
<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <!-- more dependencies --> 

    </dependencies> 
</dependencyManagement> 

的更多信息,可在Introduction to the Dependency Mechanism