Parent pom: globally defines the project model. The child pom inherits the configuration of the parent pom.
Main configuration: define basic project information, such as license <licenses> <license> <Name> the Apache software license, version 2.0 </Name> <URL> http://www.apache.org/licenses/LICENSE-2.0.txt </URL> <distribution> repo </distribution> </license> </licenses>
Define the company's unified repository location: for example, jardeploy location <! -- Publish location configuration --> <distributionmanagement> <repository> <ID> nexus-releases </ID> <Name> internal release repository </Name> <URL> http://nexus.xxx.com/content/repositories/releases/ </URL> </Repository> <snapshotrepository> <ID> nexus-snapshots </ID> <Name> internal snapshot repository </Name> <URL> http://nexus.xxx.com/content/repositories/snapshots/ </URL> </snapshotrepository> </distributionmanagement>
Define global plug-ins: for example, <plugins> <plugin> <inherited> true </inherited> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-compiler-plugin </artifactid> <configuration> <source> 1.6 </source> <target> 1.6 </Target> <optimize> true </optimize> <debug> true </debug> </configuration> </plugin> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-resources-plugin </artifactid> <configuration> <encoding> UTF-8 </encoding> </configuration> </plugin>
<! -- Release source code jar --> <plugin> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-source-plugin </artifactid> <version> 2.1.2 </version> <executions> <execution> <ID> attach-sources </ID> <phase> deploy </phase> </execution> </executions> </plugin>
<! -- Release javadoc --> <plugin> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-javadoc-plugin </artifactid> <version> 2.8.1 </version> <executions> <execution> <ID> attach-javadocs </ID> <goals> <goal> jar </goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Unified management of jar versions: you do not need to add the version and scope attributes to the sub-project when introducing jar: for example, <! -- Manage the jar package version --> <dependencymanagement> <dependencies> <dependency> <groupid> com. peaceful </groupid> <artifactid> nuggets-peaceful-utils </artifactid> <version> 1.0-Snapshot </version> </dependency> </dependencies> </dependencymanagement>
Define the company's unified jar package dependency: in this way, all projects that configure parent can depend on the following JAR files in their own projects, such as <dependencies>
<! -- JUnit dependency for testing --> <dependency> <groupid> JUnit </groupid> <artifactid> JUnit </artifactid> <version >$ {JUnit. version }</version> <scope> test </scope> </dependency> </dependencies>
Summary parent Pom is mainly used to describe the project model globally.
Maven parent POM