Transitive dependency not included in war package

2019-07-29 10:17发布

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

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

Any suggestions? Using Maven 3

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.

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

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)

1条回答
forever°为你锁心
2楼-- · 2019-07-29 10:43

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

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

查看更多
登录 后发表回答