在Maven中跟踪托管依赖项版本

问题描述 投票:8回答:2

说我有一个有很多依赖项的复杂项目。依赖项的版本由许多导入作用域poms管理。我的项目依赖于工件group:artifact,而依赖于工件group:transitive-dependency。当我运行dependency:tree时,我会看到类似这样的内容:

+- group:artifact:jar:1.3
   +- group:transitive-dependency:jar:1.1 (version managed from 1.3)

问题是group:artifact:1.3需要group:transitive-dependency 1.3版或更高版本。确定其中一个导入poms强制使用了错误的版本。但是除了搜索所有的对象之外,还有什么方法可以知道是哪一个?

maven dependencies pom.xml
2个回答
5
投票

您应该尝试使用maven-enforcer-plugin并将其配置为执行DependencyConvergence,例如

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.2</version>
    <executions>
      <execution>
        <id>enforce</id>
        <configuration>
          <rules>
            <DependencyConvergence/>
          </rules>
        </configuration>
        <goals>
          <goal>enforce</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

这将向您显示哪些顶级依赖项在其依赖项树中具有其他依赖项的不同版本。然后,使用排除排除不需要的依赖项变体。


2
投票

[当两个或多个父Poms与同一工件冲突时发生。

例如:

[INFO] |  \- com.rbs.gbm.risk:framework-core:jar:1.6.6:compile
[INFO] |     +- com.rbos.gbm.risk:log4jextensions:jar:2.3:compile (version managed from 2.2)
[INFO] |     +- oro:oro:jar:2.0.8:compile

就我而言,framework-core提到了log4jextentsions 2.2。我的超级pom说log4jextentsions 2.3。框架核心以某种方式说服了Maven使用log4jextentsions 2.2。

稍后更新框架核心pom以使用2.3时:

[INFO] |  \- com.rbs.gbm.risk:framework-core:jar:1.6.6:compile
[INFO] |     +- com.rbos.gbm.risk:log4jextensions:jar:2.3:compile
[INFO] |     +- oro:oro:jar:2.0.8:compile
© www.soinside.com 2019 - 2024. All rights reserved.