One, Dependencymanagement Unified multi-module dependent version
If your project has multiple sub-modules, and each module needs to introduce dependencies, but for the project to work correctly, you must have all of the subproject (sub-projects referred to as sub-modules) use a consolidated version of the dependencies to ensure that the same results are tested and published. So how to ensure that the version between the modules is consistent.
Maven uses Dependencymanagement to unify the dependency version of the module.
In the parent project's Pom file, we will use the dependencymanagement element. It manages the version of the jar package so that the subproject references a list version number that is dependent instead of being displayed. Maven walks up the parent-child hierarchy until it finds a project that has a dependencymanagement element, and then it uses the version number specified in the Dependencymanagement element.
For example: Pom.xml in the top level
[HTML] View plain copy <dependencyManagement> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${javaee-api.version}</version> </dependency> </dependencies> </dependencyManagement>
Dependency on the use of parent pom.xml in child modules:
[html] View Plain copy <!--inherit parent class--> <parent> <artifactId> Parent artifactid</artifactid> <groupId> Father groupid</groupid> <version > Parent version</version> <relativePath> Parent Pom.xml relative path </relativePath> </parent> <!--dependency--> <dependencies> <dependency> <groupId>javax</groupId> <artifactid>javaee-api</artifactid > </dependency> </dependencies>