战争包中未包含传递性依赖 [英] Transitive dependency not included in war package

查看:98
本文介绍了战争包中未包含传递性依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个战争项目依赖于com.mycompany:somejarname:1.0.它取决于slf4j-log4j12(仅在运行时由该jar才需要).

A war project is dependent on com.mycompany:somejarname:1.0. It is dependent on slf4j-log4j12 (this is needed only at runtime by that jar).

打包的战争不包括slf4j-log4j12-我的理解是,应将其包括在内,因为由于传递依赖性:war-> somejarname-> slf4j-log4j12.依存关系树确实显示了依存关系,但是它不包含在最终的战争包中.

The packaged war doesn't include slf4j-log4j12- my understanding is that it should be included since because of transitive dependency: war --> somejarname --> slf4j-log4j12. The dependency tree does show the dependency but it is not included in the final war package.

[INFO] +- com.mycompany:somejarname:jar:1.0:compile
[INFO] |  +- common-crypt:common-crypt:jar:1.0:compile
[INFO] |  +- org.apache.axis2:axis2-spring:jar:1.5.1:compile
[INFO] |  +- org.objenesis:objenesis:jar:1.1:compile
[INFO] |  +- org.mockito:mockito-all:jar:1.9.0:compile
[INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.5.6:compile
[INFO] |  \- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO] |     \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile

有什么建议吗?使用Maven 3

Any suggestions? Using Maven 3

更新:这适用于Maven 2.2.1,但不适用于Maven 3.0.4. Maven 3中的依赖性解析已更改从2.2.1开始.

UPDATE: this works with Maven 2.2.1, but not with Maven 3.0.4. Dependency resolution in Maven 3 was changed from 2.2.1.

更新:依赖关系树" 功能与Maven 2.2.1中的功能相同,因此上面的树显示了slf4j-log4j12.

UPDATE: dependency tree functionality in Maven 3 is same as in Maven 2.2.1 so the tree above shows slf4j-log4j12.

此外,并非Maven 2.x分辨率API的所有部分都可以桥接到Aether.最值得注意的是,用于mvn依赖关系的maven-dependency-tree共享组件:tree仍使用旧式解析代码.因此,mvndependency:tree的输出可能与Maven本身用于导出项目的类路径的实际依赖关系树不同(有关这种差异的示例,请参见MSHARED-167)

Furthermore, not all parts of the Maven 2.x resolution API could be bridged onto Aether. Most notably the maven-dependency-tree shared component which is used for mvn dependency:tree still uses the legacy resolution code. As such, the output from mvn dependency:tree can differ from the actual dependency tree used by Maven itself to derive the classpaths of a project (see MSHARED-167 for an example of such a discrepancy)

推荐答案

使用Eclipse Mars的Maven 3.2.5(m2e插件)发现了相同的问题.

Found the same issue using Maven 3.2.5 from Eclipse Mars (m2e plugin).

使用默认与Eclipse Mars打包在一起的Maven 3.3.3 (需要Java 7或8)解决.

Solved it by using Maven 3.3.3 (needs Java 7 or 8) that comes packaged by default with Eclipse Mars.

这篇关于战争包中未包含传递性依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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