I'm fashionably late to this question, but I think it's worth a clearer response than the accepted one (which is correct, but doesn't emphasize the actual important part, which you need to deduce yourself).
(对于这个问题,我时兴地晚了,但是我认为这比被接受的答案更明确的回答是值得的(这是正确的,但并不强调您需要推论的实际重要部分)。)
In the parent POM, the main difference between the <dependencies>
and <dependencyManagement>
is this:
(在父POM中, <dependencies>
和<dependencyManagement>
之间的主要区别是:)
Artifacts specified in the <dependencies>
section will ALWAYS be included as a dependency of the child module(s).
(<dependencies>
部分中指定的工件将始终作为子模块的依赖项包括在内。)
Artifacts specified in the <dependencyManagement>
section, will only be included in the child module if they were also specified in the <dependencies>
section of the child module itself.
(如果在<dependencyManagement>
部分中指定的工件,也必须在子模块本身的<dependencies>
部分中指定,则它们将仅包含在子模块中。)
Why is it good you ask? (你问为什么好?)
because you specify the version and/or scope in the parent, and you can leave them out when specifying the dependencies in the child POM. (因为您在父级中指定了版本和/或范围,并且可以在子级POM中指定依赖项时将其忽略。)
This can help you use unified versions for dependencies for child modules, without specifying the version in each child module. (这可以帮助您将统一版本用于子模块的依赖性,而无需在每个子模块中指定版本。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…