简体   繁体   English

是否应通过“导入”作用域将所有第3方jar依赖项引入Maven?

[英]Should all 3rd-party jar dependencies be introduced to Maven via 'import' scope?

So confused about import scoping in Maven. 对Maven中的导入范围感到困惑。 It seems to imply that all 3rd-party jar dependencies in a large, muti-module project would benefit from being dependency managed in the parent using the 'import' scope. 似乎暗示大型多模块项目中的所有第3方jar依赖项都将从使用“导入”范围在父级中进行依赖项管理中受益。 Is that correct? 那是对的吗?

From maven's documentation about the import scope: 从有关import范围的maven文档中:

This scope is only used on a dependency of type pom in the section. 该范围仅在本节中用于pom类型的依赖项上。 It indicates that the specified POM should be replaced with the dependencies in that POM's section. 它指示应使用该POM部分中的依赖项替换指定的POM。 Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency. 由于已替换它们,因此具有导入范围的依赖项实际上并不参与限制依赖项的可传递性。

Frankly, this is usually isn't a very useful scope, and in any event it is not relevant for 3rd party jar dependencies - only for 3rd party pom dependencies. 坦白说,这通常不是一个非常有用的范围,无论如何,它与第三方jar依赖关系无关-仅与第三方pom依赖关系无关。 Where you place dependencies is somewhat a matter of taste, but the practice I found worked best for me was to place all the dependencies in the "lowest common denominator" pom's <dependencyManagement> section, and then referencing them in the <dependencies> section of the specific subprojects as needed. 当您将依赖是有点品味的问题,但我发现实践中摸索最适合我的是发生在“最小公分母”的所有依赖的pom的<dependencyManagement>部分,然后参考他们在<dependencies>的部分所需的特定子项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM