在Maven中跟踪托管依赖项版本 [英] Tracking managed dependency versions in Maven

查看:234
本文介绍了在Maven中跟踪托管依赖项版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Say I have a complex project with lots of dependencies. The versions of the dependencies are managed by lots of import scope poms. My project has a dependency on artifact group:artifact, which has a dependency on artifact group:transitive-dependency. When I run dependency:tree I see something like this:

+- 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强制使用了错误的版本.但是除了搜索所有的对象之外,还有什么方法可以知道是哪一个?

The problem is group:artifact:1.3 requires group:transitive-dependency version 1.3 or higher. Sure one of the import poms is forcing the wrong version. But is there any way to know which one is, other than searching through all of them?

推荐答案

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

You should try the maven-enforcer-plugin and configure it to do DependencyConvergence, e.g.

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

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

That will show you which top level dependencies have different versions of other dependencies in their dependency trees. You then suppress the dependency variants that you don't want using exclusions.

这篇关于在Maven中跟踪托管依赖项版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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