我是 Java 和 Maven 新手。 我有 2 个项目代码(A 和 B),这样。 A依赖于B,B依赖于C(第三方) 但项目 A 也依赖于 C。
我可以在 A 的 pom.xml 中指定从 B 获取 C 的依赖吗?
我只想在 A 的 pom.xml 中提及对 B 及其 Jars 的依赖。
这样,如果 B 的 pom.xml 中的 C 发生任何版本更改,我就不必在 A 的 pom.xml 中进行相同的更改
最佳答案
Can I specify in pom.xml of A to take the dependency of C from B?
如果 A 依赖于 B,而 B 又依赖于 C,则 A 会传递性地拉取 C 的依赖。因此,您无需在 A 中声明 C,甚至不应避免使用不同的版本。
Transitive dependencies are a new feature in Maven 2.0. This allows you to avoid needing to discover and specify the libraries that your own dependencies require, and including them automatically.
关于java - 使用 Maven 管理多重依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45387705/