Maven 如何解决依赖冲突? [英] How does Maven resolve dependency conflicts?

查看:98
本文介绍了Maven 如何解决依赖冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一个项目 A.

Let's assume we have a Project A.

  • 项目 A 依赖于项目 B 1.0 版
  • 项目 A 依赖于项目 C 版本 2.0
  • 项目 C(2.0 版)依赖项目 B 2.0 版

在这种情况下,Maven 将如何解决冲突?

In this case, how would Maven resolve the conflict?

推荐答案

它将使用 Project B v 1.0 构建

It'd build with Project B v 1.0

您可以使用 http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html看,它省略了 B 2.0 因为 1.0 更接近.

You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html to see, that it omitted B 2.0 cause 1.0 is nearer.

来自上面的页面:

默认 Maven 使用最近赢策略解决版本冲突.

by default Maven resolves version conflicts with a nearest-wins strategy.

输出是这样的:

[INFO] [dependency:tree]
[INFO] Project A
[INFO] +- Project-B:jar:1.0:compile
[INFO] \- Project-C:jar:2.0:compile
[INFO]    \- (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)

这篇关于Maven 如何解决依赖冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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