1. Inheritance
Why ① need to inherit.
We know that the dependency transitivity between MAVEN projects is actually the transitivity of dependency between jar packages and war packages, but it must be compile-scoped dependencies that are transitive in order to manage a dependent version on a consistent basis. Depending on the test scope, which exists only in a single project, depending on the version of each project may be different and prone to problems, the problem of the unified version of the test scope depends on the transitive nature of dependencies that cannot be solved. So we use the concept of inheritance to solve.
② How to implement inheritance
Inheritance, as the name suggests, there is a parent-child relationship. We need to define a parent project that manages some of the test scope dependencies uniformly, and the way it is packaged is POM. Declare the dependent coordinates of the test range in its pom file. Then in the subproject the first declaration of the parent project coordinates in the form of <parent> coordinates </parent> declares the dependent coordinates of the test range, and also declares the dependent coordinates of the test scope in the subproject. However, it is important to note that the version number in the coordinates must be removed before you can complete the unified management test range-dependent version.
2. Polymerization
Why ① Need aggregation
We will eventually talk about each MAVEN project installed into the warehouse, but because of the inheritance relationship makes it necessary to install the parent project before you can install the subproject, or it will be an error. and must be one by one install. So can there be a better way to complete a one-click installation. The polymerization project can be completed.
② How to achieve aggregation
We first define a package for the POM project as an aggregation project, and in which a MAVEN project is aggregated in the form of a <models><model></model></models> tag , it does not have to be in the order of the model, it automatically recognizes the parent project to complete the installation first. Then only then will this polymerization engineering install then the aggregation in the project can be smooth install.
It should be noted that in the actual project development project, we can use the same POM packaging project to act as a parent engineering and polymerization project. The effect is that the Pom.xml file contains a test-scoped dependency and a models tag that aggregates each MAVEN project.