[英]Maven dependency not in pom.xml
我有一个使用spring的项目。 它使用版本3.1.1,但是由于某些我真的不知道的原因,一些弹簧工件被两个不同的版本所复制。 我在我的项目的所有pom.xml文件中寻找那些依赖项。 我还使用Dependecy插件来找出那些依赖项在哪里。
在这里,您可以提取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
了范围的依赖关系,但是我需要知道为什么会这样。
更新 :看来,当我评论下一个代码时,罐子不包括在战争中。
<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>
spring-context
pom定义了对spring-core
的依赖关系,其版本与spring-context
完全相同。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
因此,您必须在项目中的某个地方有一个dependencyManagement
,它告诉maven使用3.0.5.RELEASE
而不是3.1.1.RELEASE
。
看看你的绒球。 dependencyManagement
必须有类似这样的东西。
<dependencyManagement>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
</dependencyManagement>
根据您的Maven版本,可能还可以使用依赖项导入 。
PS: spring-asm
相同
如果我仅将org.springframework:spring-web:jar:3.1.1.RELEASE
到项目中,并通过org.springframework:spring-web:jar:3.1.1.RELEASE
mvn dependency:tree
显示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.1.1.RELEASE:compile
[INFO] \- org.springframework:spring-core:jar:3.1.1.RELEASE:compile
[INFO] \- commons-logging:commons-logging:jar:1.1.1:compile
从未引用过org.springframework:spring-core:jar:3.0.5.RELEASE
或org.springframework:spring-asm:jar:3.0.5.RELEASE
。 这意味着您有另一个引入该依赖的依赖项,或者您正在使用dependencyManagement块覆盖该依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.