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?
它下載其他版本,因爲您的項目所需的其他庫的依賴關係。您可以讓maven不要下載(幷包含)該依賴關係。 – 2012-03-17 15:33:22
我怎麼看?是否有Maven命令列出所有依賴關係,甚至包括其他依賴關係所需的依賴關係? – vrutberg 2012-03-17 15:36:08
在eclipse中,至少在最後一個版本中,有一些pom視圖,你可以看到依賴關係樹,因此你可以找出爲什麼一個庫被添加爲其他依賴關係的後果。 – jddsantaella 2012-03-17 19:41:56