Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Maven Reading Notes (3) inheritance and aggregation

Shulou Source: shulou.com Published: 2022-06-03 07:01:17 10月03日 Update

For clearer design and higher reusability, software designer Wangwang will divide the software into modules in various ways. Inheritance and aggregation are used in maven to simplify the configuration and operation of modules. The similarities and differences between them are as follows:

1. The aggregation module is used to simplify the compilation and packaging of the project, and all modules can be operated through direct operation of the aggregation module; inheritance is mainly to simplify configuration and save the unity of each module, the announced part can be extracted and put into the parent project, such as dependent version, plug-in settings and other extended attribute settings.

two。 The inheritance and aggregation modules that need to be established separately are used to support aggregation and inheritance functions, and the packaging of this module is pom. Generally speaking, inheritance and aggregation are placed in the same module to provide both aggregation and inheritance functions.

3. In order to operate all sub-modules through the aggregation module, the aggregation module needs to rely on each sub-module, and the relative path of the sub-module needs to be specified through modules in the pom of the aggregation module; in order to achieve the configuration of using the parent project in the sub-project, the sub-project needs to rely on the parent project, and the parent project coordinates and their paths need to be specified forcefully in the sub-project, which is specified through the parent tag. In addition, if a project does not specify a parent project, it specifies super pom by default (the top-level project in maven, which is equivalent to Object in java).

4. It is best to have a unified groupId and a unified version for each module in the project. This can be easily achieved by specifying groupId and version in the parent project.

5. To reduce package conflicts and plug-in conflicts, it is best to specify the version of the package and the settings of the plug-in in the parent project. DependencyManagement and pluginManagement.

Tags: Modules projects plug-ins unification configuration middle finger function way best version path software project conflict design in general size people announcements can be obtained through the Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Apple macOS Linux Huawei