Maven DependencyManagerment

Posted Jun 26, 20201 min read

In the POM file at the top level of the project, you will see the dependencyManagement element. Use it to manage the version of the jar package, so that the subproject references a dependency instead of the listed version number. Maven will walk up the parent-child hierarchy until it finds a project with a dependencyManagement element, and then it will use the version number specified in the dependencyManagement element.

dependencies Even if the dependency is not written in the child project, the child project will still inherit the dependency from the parent project(all inheritance)
dependencyManagement only declares the dependency, does not implement the introduction, so the subproject needs to display the required dependencies. If you do not declare a dependency in the child project, it will not be inherited from the parent project; only if the dependency is written in the child project and no specific version is specified, will the item be inherited from the parent project, and the version and scope Both are read from the parent pom; in addition, if the version number is specified in the child project, then the jar version specified in the child project will be used.
The jar in is directly added to the project, and the dependency relationship is managed(if there is a parent pom and a child pom, the child pom can only passively accept the parent version); Main Managing versions is very useful for subclasses to inherit the same parent class. Centrally managing dependent versions does not add dependencies. For the versions defined in it, the child pom does not have to inherit the version defined by the parent pom.