2012-03-17 42 views
3

在我的Maven项目中,我定义了一堆Spring依赖关系,并且我注意到在某些情况下,它会选择不同版本的构件,尽管它们在我的pom.xml中被指定为相同。为什么Maven会下载不同版本的Spring工件?

这是mvn dependency:tree

[INFO] com.vrutberg.blogping:blogping:war:1.0-SNAPSHOT 
[INFO] +- junit:junit:jar:4.7:test 
[INFO] +- javax.servlet:servlet-api:jar:2.4:compile 
[INFO] +- com.sun.jersey:jersey-server:jar:1.12:compile 
[INFO] | +- asm:asm:jar:3.1:compile 
[INFO] | \- com.sun.jersey:jersey-core:jar:1.12:compile 
[INFO] +- com.sun.jersey:jersey-bundle:jar:1.12:compile 
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:compile 
[INFO] +- org.springframework:spring-core:jar:3.0.0.RC3:compile 
[INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile 
[INFO] +- org.springframework:spring-beans:jar:3.0.0.RC3:compile 
[INFO] +- org.springframework:spring-aop:jar:3.0.0.RC3:compile 
[INFO] +- org.springframework:spring-context:jar:3.0.0.RC3:compile 
[INFO] +- org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile 
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile 
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile 
[INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile 
[INFO] | \- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile 
[INFO] +- org.springframework:spring-oxm:jar:3.0.5.RELEASE:compile 
[INFO] +- org.springframework:spring-web:jar:3.0.0.RC3:compile 
[INFO] +- org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile 
[INFO] | \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile 
[INFO] +- org.springframework:spring-test:jar:3.0.5.RELEASE:test 
[INFO] \- com.sun.jersey.contribs:jersey-spring:jar:1.12:compile 
[INFO] \- com.sun.jersey:jersey-servlet:jar:1.12:compile 

在我的pom.xml大纲我定义我的所有春天的文物使用属性,它的定义,像这样:

<org.springframework.version>3.0.5.RELEASE</org.springframework.version> 

而这些是我的依赖关系:

<!-- spring libraries --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-expression</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context-support</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-oxm</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-test</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>test</scope> 
    </dependency> 

为什么地球上它使用不同的版本?

编辑:

好吧,所以我刚刚发现了这些警告。我想这与它有关:

Downloading: http://download.java.net/maven/2/org/springframework/spring-core/3.0.0.RC3/spring-core-3.0.0.RC3.pom 
Downloading: http://repo1.maven.org/maven2/org/springframework/spring-core/3.0.0.RC3/spring-core-3.0.0.RC3.pom 
[WARNING] Missing POM for org.springframework:spring-core:jar:3.0.5.RELEASE 
Downloading: http://download.java.net/maven/2/org/springframework/spring-beans/3.0.0.RC3/spring-beans-3.0.0.RC3.pom 
Downloading: http://repo1.maven.org/maven2/org/springframework/spring-beans/3.0.0.RC3/spring-beans-3.0.0.RC3.pom 
[WARNING] Missing POM for org.springframework:spring-beans:jar:3.0.5.RELEASE 
Downloading: http://download.java.net/maven/2/org/springframework/spring-aop/3.0.0.RC3/spring-aop-3.0.0.RC3.pom 
Downloading: http://repo1.maven.org/maven2/org/springframework/spring-aop/3.0.0.RC3/spring-aop-3.0.0.RC3.pom 
[WARNING] Missing POM for org.springframework:spring-aop:jar:3.0.5.RELEASE 
Downloading: http://download.java.net/maven/2/org/springframework/spring-context/3.0.0.RC3/spring-context-3.0.0.RC3.pom 
Downloading: http://repo1.maven.org/maven2/org/springframework/spring-context/3.0.0.RC3/spring-context-3.0.0.RC3.pom 
[WARNING] Missing POM for org.springframework:spring-context:jar:3.0.5.RELEASE 
Downloading: http://download.java.net/maven/2/org/springframework/spring-web/3.0.0.RC3/spring-web-3.0.0.RC3.pom 
Downloading: http://repo1.maven.org/maven2/org/springframework/spring-web/3.0.0.RC3/spring-web-3.0.0.RC3.pom 
[WARNING] Missing POM for org.springframework:spring-web:jar:3.0.5.RELEASE 

为什么poms缺少一些工件?为什么会回到使用3.0.0.RC3?

+0

它下载其他版本,因为您的项目所需的其他库的依赖关系。您可以让maven不要下载(并包含)该依赖关系。 – 2012-03-17 15:33:22

+0

我怎么看?是否有Maven命令列出所有依赖关系,甚至包括其他依赖关系所需的依赖关系? – vrutberg 2012-03-17 15:36:08

+2

在eclipse中,至少在最后一个版本中,有一些pom视图,你可以看到依赖关系树,因此你可以找出为什么一个库被添加为其他依赖关系的后果。 – jddsantaella 2012-03-17 19:41:56

回答

3

在eclipse中,至少在最后一个版本中,有一个pom视图,您可以在其中查看依赖关系树,以便了解为什么将库添加为其他库的后果。

相关问题