Maven:我应该保留还是删除声明的依赖关系,它们也是传递依赖关系? [英] Maven : Should I keep or remove declared dependencies that are also transitives dependencies?
问题描述
您认为删除 maven pom 中可以找到的所有传递依赖项是一个好习惯吗?
Do you think it is a good practice to remove every transitive dependencies that can be found in a maven pom?
示例:
我的项目依赖于 A 和 B.
B 也是 A 的传递依赖.
我应该将 B 保留在我的 pom 中还是删除它?
Example:
My project depends on A and B.
B is also a transitive dependency of A.
Should I keep B in my pom or remove it ?
什么是最好的:
在 pom 上声明所有已知的罐子,甚至是传递的罐子,还是只保留顶级罐子?
What is the best:
having all known jars, even transitive one, declared on the pom or keeping only the top level jars ?
这有点主观,但我正在尝试清理一些具有大量传递依赖项的巨大 pom(父子节点).我想让我的 pom 尽可能简单,但我也希望它们是可维护的.
This is a little bit subjective, but I am trying to clean some huge poms (parent and children) with a lot of transitive dependencies. I want to keep my pom as simple as possible, but I want also them to be maintainable.
推荐答案
如果你的项目对 B 有直接依赖,那么即使 B 是 A 的传递依赖,你也应该保留它.可能在下一个版本中 A 赢了'不要使用 B 你将不得不重组 pom.xml.
If your project has direct dependencies on B then you should keep it even if B is a transitive dependency of A. It can be that in the next version A won't use B an you'll have to restructure the pom.xml.
通常,Maven 依赖项应该反映逻辑项目依赖项.
Generally, Maven dependencies should reflect the logical project dependencies.
这篇关于Maven:我应该保留还是删除声明的依赖关系,它们也是传递依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!