【问题标题】:Transitive dependency not included in war packagewar包中不包含传递依赖
【发布时间】:2012-07-23 03:54:51
【问题描述】:

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

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

[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

更新:这适用于 Maven 2.2.1,但不适用于 Maven 3.0.4。 Maven 3 中的 Dependency resolution 从 2.2.1 更改。

更新:Maven 3 中的dependency tree 功能与 Maven 2.2.1 中的功能相同,因此上面的树显示 slf4j-log4j12。

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

【问题讨论】:

  • 没有pom文件很难猜出什么问题?
  • pom 包含很多组件——我将尝试在一个较小的项目中重现它,然后发布 POM
  • 问题解决了吗?如果是这样,请将解决方案发布为答案。
  • 我已经在我的战争项目中明确列出了依赖关系(war --> somejarname --> slf4j-log4j12)。当我尝试使用较小的项目时,我无法重现此问题。

标签: maven-2 maven-3


【解决方案1】:

使用来自 Eclipse Mars(m2e 插件)的 Maven 3.2.5 发现了同样的问题。

使用 Eclipse Mars 默认打包的 Maven 3.3.3(需要 Java 7 或 8)解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    相关资源
    最近更新 更多