解释“省略冲突".在Maven 2依赖树中 [英] Interpreting "omitted for conflict" in maven 2 dependency tree

查看:72
本文介绍了解释“省略冲突".在Maven 2依赖树中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是Maven 2.2.1使用以下命令生成的依赖关系树 mvn -o dependency:tree -Dverbose -Dincludes=log4j

This is a dependency tree generated by Maven 2.2.1 with mvn -o dependency:tree -Dverbose -Dincludes=log4j

[INFO] [dependency:tree {execution: default-cli}]
[INFO] com.openboxes.renderingservice:common:jar:1.0
[INFO] +- org.springframework:spring:jar:2.0.4:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1:compile
[INFO] |     \- log4j:log4j:jar:1.2.12:compile
[INFO] \- it.mycompany.portal:server:jar:1.5-SNAPSHOT:compile
[INFO]    \- org.slf4j:slf4j-log4j12:jar:1.1.0:compile
[INFO]       \- (log4j:log4j:jar:1.2.13:compile - omitted for conflict with 1.2.12)

如您所见,log4j v1.2.12优于v1.2.13.

As you can see log4j v1.2.12 is preferred over v1.2.13.

我知道"Maven使用最近的获胜策略解决版本冲突"(请参阅​​

I know that "Maven resolves version conflicts with a nearest-wins strategy" (see http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html) but these two dependencies seem to be at the same distance (two nesting levels, am I wrong?) so I expect that the most recent one is used.

有人可以解释这个结果吗?

Can someone explain this result?

是的,在此POM中没有明确声明log4j(我认为应该这样声明),但是我想更好地了解Maven的工作方式.

Yes, log4j is not explicitly declared in this POM (and I think it should be), but I would like to better understand the way Maven works.

Thx

推荐答案

我已经在

I've found the answer by myself at http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html: "if two dependency versions are at the same depth in the dependency tree, until Maven 2.0.8 it was not defined which one would win, but since Maven 2.0.9 it's the order in the declaration that counts: the first declaration wins".

对我来说,这似乎是一个非常可疑的策略. :-\

It seems a very questionable strategy to me. :-\

这篇关于解释“省略冲突".在Maven 2依赖树中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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