- In the dependency tree of engineering, the shallower the depth is, the more priority is given.
- If two dependent packages are at the same level on the dependency tree, who is the first to choose the other
- In summary, best practices for avoiding version problems when passing dependencies. In general, if the project directly depends on multiple modules of a certain framework, it is betterDeclare all of these dependencies
Module aggregation and inheritance
When there are many modules, you want to build multiple projects at a time instead of executing commands separately in the directory of multiple modules. Maven’s aggregation feature serves this requirement.
<parent> <groupId>com.ts.mall</groupId> <artifactId>ts-mall</artifactId> <version>0.0.1-SNAPSHOT</version> <relativePath>../mall-dependencies/pom.xml</relativePath> </parent> <artifactId>mall-dependencies</artifactId> <! -- aggregation module must be POM, otherwise it cannot be built -- > <packaging>pom</packaging> <! -- modules is the core configuration to implement aggregation. Specify the module directory for Aggregation -- > <modules> <module>../modules1</module> <module>../modules2</module> <module>../modules3</module> </modules>
- The grouopid and version of the child module are dependent on the parent module.
- A module does not need to rely on the parent class of jar package, need to use Maven dependency management dependency management to solve this problem
- Aggregation is to facilitate rapid construction of projects
- Inheritance is to eliminate duplicate configuration, which can simplify POM and promote the consistency of each module configuration.
- The common point is that the packaging of the two modules is POM, and the parent module in the aggregation module and the inheritance relationship have no actual content except POM.
Maven practice (9) — module aggregation and inheritance