首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Maven依赖项不在pom.xml中

Maven依赖项不在pom.xml中
EN

Stack Overflow用户
提问于 2014-01-28 12:39:55
回答 2查看 2.3K关注 0票数 0

我有一个使用spring的项目。它使用3.1.1版本,但由于某些原因我真的不知道,一些spring工件被复制成两个不同的版本。我在我的项目的所有pom.xml文件中查找那些依赖项。我还使用了依赖插件来找出那些依赖项包含在哪里。

这里有一个mvn dependency:tree输出的摘录

代码语言:javascript
运行
复制
[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的依赖项,但我需要知道为什么会发生这种情况。

更新:当我评论下一段代码时,war中似乎没有包含jars。

代码语言:javascript
运行
复制
<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>
EN

回答 2

Stack Overflow用户

发布于 2014-01-28 12:51:08

spring-context pom使用与spring-context完全相同的版本定义了对spring-core的依赖关系。

代码语言:javascript
运行
复制
<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中肯定有类似的东西。

代码语言:javascript
运行
复制
<dependencyManagement>
    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-core</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
</dependencyManagement>

根据您的maven版本,也可能使用依赖项导入

PS:同样适用于spring-asm

票数 0
EN

Stack Overflow用户

发布于 2014-01-28 12:52:09

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

代码语言:javascript
运行
复制
[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块覆盖该依赖项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21405791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档