Maven依赖项不在pom.xml中 [英] Maven dependency not in pom.xml

查看:404
本文介绍了Maven依赖项不在pom.xml中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用spring的项目.它使用版本3.1.1,但是由于某些我真的不知道的原因,一些弹簧构件被复制到两个不同的版本中.我从项目中的所有pom.xml文件中查找那些依赖项.我还使用dependecy插件来找出那些依赖项在哪里.

I have a project which uses spring. It uses version 3.1.1 but, for some reason I really don't know, some spring artifacts are duplicated with two different versions. I look for the those dependencies in all pom.xml files from my project. I also use the dependecy plugin to figure out where were those dependencies included.

在这里您提取了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中.

As far as I know this means that org.springframework:spring-core:jar:3.0.5.RELEASE:compile is included in org.springframework:spring-web:jar:3.1.1.RELEASE:compile.

我要解决此问题,包括范围为provided的依赖项,但我需要知道为什么会这样.

I workaround this including a dependency with scope provided but I'd need to know why is this happening.

更新: 看来,当我评论下一个代码时,战争中就不包括罐子了.

Update: It seems that when I comment the next code the jars are not included in the war.

<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>

推荐答案

如果我仅将org.springframework:spring-web:jar:3.1.1.RELEASE添加到项目中并通过mvn dependency:tree显示树,则会显示以下输出:

If i add only the org.springframework:spring-web:jar:3.1.1.RELEASE to a project and show the tree via mvn dependency:tree the following output appears:

[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.RELEASEorg.springframework:spring-asm:jar:3.0.5.RELEASE.这意味着您有另一个引入该依赖的依赖项,或者您正在使用dependencyManagement块将其覆盖.

wher never got a reference to org.springframework:spring-core:jar:3.0.5.RELEASE or org.springframework:spring-asm:jar:3.0.5.RELEASE. This means you have an other dependency which introduces that or you are using a dependencyManagement block overwrites that.

这篇关于Maven依赖项不在pom.xml中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆