here is a description of the difference between declaring dependencymanagement and dependencies in the root node of the parent projectDependencymanagement
Maven uses the Dependencymanagement element to provide a way to manage dependent version numbers. The dependencymanagement element is typically seen in the parent pom at the top level of an organization or project. Using the Dependencymanagement element in Pom.xml can make
All references a dependency in a subproject without explicitly listing the version number. Maven walks up the parent-child hierarchy until a project with the dependencymanagement element is found, and then it uses the version number specified in the Dependencymanagement element.
For example, in the parent project:
XML code
- < Dependencymanagement >
- < Dependencies >
- < dependency >
- < groupId > mysql</ groupId >
- < artifactId > Mysql-connector-java</ artifactId >
- < version > 5.1.2</ version >
- </ Dependency >
- ...
- < Dependencies >
- </ dependencymanagement >
You can then add mysql-connector to a subproject without specifying a version number, for example:
XML code
- < Dependencies >
- < dependency >
- < groupId > mysql</ groupId >
- < artifactId > Mysql-connector-java</ artifactId >
- </ dependency >
- </ Dependencies >
The advantage of this is that if you have multiple sub-projects that reference the same dependency, you can avoid declaring a version number in each subproject, so that when you want to upgrade or switch to another version, you only need to update it in the top-level parent container, without the modification of a single subproject In addition, if a subproject requires a different version, you only need to declare version.
Dependencymanagement only declares dependencies and does not implement ingestion, so the subproject needs to explicitly declare the dependencies that need to be used.
Dependencies
As opposed to dependencymanagement, all claims in dependencies are automatically introduced and inherited by all sub-projects by default.
Dependencymanagement and dependencies in maven