我对maven如何处理传递依赖以及它如何写入类路径感到非常困惑。
假设我有两条 E 路径(A、B、C、D、E 是 ejb):
1. A<---B<---E(E 依赖(comile)于 B,而 B 又依赖于 A)
2. A<---C<---D<---E(所有依赖均为编译依赖)
问题是:E 是如何构建的,以及 E 的类路径(META-INF)中有哪些 Artifact 。
非常感谢!
最佳答案
Maven 将使用“最近的定义”来确定在构建中使用哪个版本的依赖项 E
。来自 official Maven documentation :
"nearest definition" means that the version used will be the closest one to your project in the tree of dependencies, eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0
在您的示例中:
1. A <--- B <--- E 1.0
2. A <--- C <--- D <--- E 2.0
将使用依赖项 E
的 1.0
版本,因为构建 A
时,该版本的路径较短。
关于java - Maven 如何将传递依赖添加到类路径中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30613713/