【发布时间】:2014-02-19 18:19:02
【问题描述】:
我有一个使用弹簧的项目。它使用 3.1.1 版本,但出于某种我真的不知道的原因,一些 spring 工件与两个不同的版本重复。我在我的项目的所有 pom.xml 文件中查找这些依赖项。我还使用依赖插件来找出这些依赖项包含在哪里。
这里有mvn dependency:tree 的输出摘录
[INFO] | | \- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO] | | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO] | | +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO] | | | +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile
[INFO] | | | +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] | | | \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
据我所知,这意味着org.springframework:spring-core:jar:3.0.5.RELEASE:compile 包含在org.springframework:spring-web:jar:3.1.1.RELEASE:compile 中。
我解决了这个问题,包括范围为 provided 的依赖项,但我需要知道为什么会发生这种情况。
更新: 似乎当我评论下一个代码时,jar 不包含在战争中。
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
...
<properties>
...
<cxf-version>2.4.2</cxf-version>
<spring.version>3.1.1</spring.version>
</properties>
【问题讨论】:
-
如果两个版本具有完全相同的依赖项和相同的工件和 groupId,我真的不敢相信这两个版本实际上都在类路径上。 Maven 应该管理它并且只包含一个。到目前为止,这一切看起来都是预期的行为,您正在尝试解决一个并非真正问题的问题。
-
尝试
mvn dependency:tree -Dverbose以获取有关它是否实际包含的更多信息。
标签: java spring maven maven-2 maven-dependency-plugin