java - On which level of the maven dependency tree are dependencies from the parent project
问题描述
I have a parent pom which has a dependency to third party jar A with version 1.0. Then I have a child project which inherits from the parent pom. This child project defines a dependency to library B which itself has the dependency to the third party jar A with version 1.1.
Does the dependency tree look like this(and therefore version 1.0 is pulled in):
Child->A(version 1.0) Child->B->A(version 1.1)
On which level of the dependency tree are the dependencies of the parent POM?
解决方案
Before dependencies are resolved, the parent and child POM are first combined into an "effective POM". You can display the effective POM using mvn
help:effective-pom
. Hence your dependency tree becomes:
(Effective POM) -> A:1.0
(Effective POM) -> B -> A:1.1
The effect is the same as if you had declared the A:1.0 dependency in the child POM. Since dependencies closer to the root "win" in Maven, A:1.0 is used.
Also, if both the parent and child POM declare a dependency to the same module, the version specified by the child overrides the one specified by the parent (= becomes the version in the effective POM).
推荐阅读
- c# - 试图在 Swift 中复制 C# POST 调用
- javascript - 在javascript中按字典顺序对数组进行排序
- node.js - 在 node.js 应用程序之间共享 MongoDb 连接
- elasticsearch - 弹性:尝试初始化同义词标记过滤器时出错
- android - PANIC:启动模拟器时损坏的 AVD 系统路径
- php - php - mysqli_fetch_assoc to to json 编码数组适用于大多数查询,但不适用于其他查询(尽管查询返回有效结果)
- python - 生成公共/私人比特币密钥
- html - Moving variable text to the right side
- c - Why won't my File.dat be read and run and how can I assign the data to a struct? - C
- python - 如何在包含每小时平均值和每小时每个平均值的相应计数的数据帧末尾添加新列。