Maven POM

POM (Project Object Model) is the core configuration file of Maven, in XML format, with the default name ofpom.xml。

POM is the basic unit of work in a Maven project. It is an XML file that contains the basic information of the project, used to describe how the project is built, declare project dependencies, and so on.

When executing a task or goal, Maven looks for the POM in the current directory, obtains the required configuration information, and then executes the goal.

The following configurations can be specified in the POM:

  • Project dependencies
  • Plugins
  • Execution goals
  • Project build profiles
  • Project version
  • Project developer list
  • Related mailing list information

Before creating a POM, we first need to describe the project group (groupId), the unique ID of the project.

<project> <!--Model version--> <modelVersion>4.0.0</modelVersion> <!--The unique identifier of the company or organization, and the path generated during configuration is also derived from it. For example, com.companyname.project-group, Maven will place the jar package built from this project in the local path: /com/companyname/project-group--> <groupId>com.companyname.project-group</groupId> <!--The unique ID of the project. A groupId may have multiple projects, and they are distinguished by artifactId.--> <artifactId>project</artifactId> <!--Version--> <version>1.0</version> </project>

All POM files require the project element and three required fields: groupId, artifactId, and version.

Node Description
project The root tag of the project.
modelVersion The model version needs to be set to 4.0.
groupId This is the identifier of the project group. It is usually unique within an organization or project. For example, a banking organization com.companyname.project-group owns all banking-related projects.
artifactId This is the identifier of the project. It is usually the name of the project. For example, Consumer Banking. groupId and artifactId together define the location of the artifact in the repository.
version

This is the version number of the project. In the artifact repository, it is used to distinguish different versions. For example:

com.company.bank:consumer-banking:1.0
com.company.bank:consumer-banking:1.1

Basic structure of a POM file:

Example

<project>
    <!-- 1. Basic Information-->
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>my-app</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <!-- 2. Meta information-->
    <name>My Application</name>
    <description>A demo project</description>
    <url>https://example.com</url>

    <!-- 3. Dependency management-->
    <dependencies>...</dependencies>

    <!-- 4. Build configuration-->
    <build>...</build>

    <!-- 5. Environment configuration-->
    <properties>...</properties>
    <repositories>...</repositories>
</project>

Project coordinates (required):

ElementDescriptionExample
modelVersionPOM model version (fixed4.0.0)<modelVersion>4.0.0</modelVersion>
groupIdOrganization/company identifier (reverse domain name)<groupId>com.example</groupId>
artifactIdProject name<artifactId>my-app</artifactId>
versionProject version<version>1.0.0</version>
packagingPackaging type (jar/war/pom)<packaging>jar</packaging>

Meta information (optional):

ElementDescription
nameProject name (for display)
descriptionProject description
urlProject homepage
licensesLicense information
organizationOrganization information

Example

<name>My Awesome App</name>
<description>A demo project for learning Maven</description>
<url>https://github.com/example/my-app</url>

Dependency Management

Dependencies of the project can be defined in the POM file:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>
ElementDescription
groupIdThe organization identifier of the dependency
artifactIdThe project name of the dependency
versionThe version of the dependency
scopeDependency scope (compile/test/provided/runtime)
optionalWhether it is an optional dependency (defaultfalse)

Plugin Management

Plugins used during the build process can also be defined in the POM file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Common plugins:

  • maven-compiler-plugin: Specify Java version

  • maven-surefire-plugin: Control test execution

  • maven-jar-plugin: Customize JAR package

Other Common Elements

properties: Define some property variables in the project.

Used to define variables and avoid duplication:

<properties>
    <java.version>11</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Reference in dependencies:

<version>${java.version}</version>

repositories: Repository configuration.

Specify remote repository:

<repositories>
    <repository>
        <id>aliyun</id>
        <url>https://maven.aliyun.com/repository/public</url>
    </repository>
</repositories>

dependencyManagement: Used to manage dependency versions, especially in multi-module projects.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>5.3.9</version>
        </dependency>
    </dependencies>
</dependencyManagement>

profiles: Used to define different build configurations, allowing builds to be performed according to different environments.

<profiles>
    <profile>
        <id>development</id>
        <properties>
            <environment>dev</environment>
        </properties>
    </profile>
    <profile>
        <id>production</id>
        <properties>
            <environment>prod</environment>
        </properties>
    </profile>
</profiles>

Inheritance and Aggregation

Inheritance:Through the parent element, a POM file can inherit the configuration of another POM file:

<parent>
    <groupId>com.example</groupId>
    <artifactId>parent-project</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

Aggregation:Through the modules element, a POM file can manage multiple sub-modules:

<modules>
    <module>module1</module>
    <module>module2</module>
</modules>

Complete Example

A simple example of a complete POM:

Example

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>my-app</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>My Application</name>
    <description>A demo project</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Parent (Super) POM

The Parent (Super) POM is Maven's default POM. All POMs inherit from a parent POM (whether or not this parent POM is explicitly defined). The parent POM contains default settings that can be inherited. Therefore, when Maven finds that it needs to download a dependency in the POM, it will download it from the default repository http://repo1.maven.org/maven2 configured in the Super POM.

Maven uses the effective POM (the Super POM plus the project's own configuration) to execute related goals. It helps developers make as few configurations as possible in pom.xml, but of course these configurations can be overridden.

Use the following command to view the Super POM default configuration:

mvn help:effective-pom

Next, we create the directory MVN/project, and create pom.xml in that directory, with the following content:

<project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <!--Model version--> <modelVersion>4.0.0</modelVersion> <!--The unique identifier of the company or organization, and the path generated during configuration is also derived from it. For example, com.companyname.project-group, Maven will place the jar package built from this project in the local path: /com/companyname/project-group--> <groupId>com.companyname.project-group</groupId> <!--The unique ID of the project. A groupId may have multiple projects, and they are distinguished by artifactId.--> <artifactId>project</artifactId> <!--Version--> <version>1.0</version> </project>

In the command console, enter the MVN/project directory and execute the following command:

C:\MVN\project>mvn help:effective-pom

Maven will start processing and display the effective-pom.

[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:36 min
[INFO] Finished at: 2018-09-05T11:31:28+08:00
[INFO] Final Memory: 15M/149M
[INFO] ------------------------------------------------------------------------

The resulting Effective POM is as shown in the console; after inheritance and interpolation, the configuration takes effect.

<?xml version="1.0" encoding="UTF-8"?> <!-- ================================================================= --> <!-- --> <!-- Generated by Maven Help Plugin on 2012-07-05T11:41:51 --> <!-- See: http://maven.apache.org/plugins/maven-help-plugin/ --> <!-- --> <!-- ================================================================= --> <!-- ================================================================= --> <!-- --> <!-- Effective POM for project --> <!-- 'com.companyname.project-group:project-name:jar:1.0' --> <!-- --> <!-- ================================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/ 2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 h ttp://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.companyname.project-group</groupId> <artifactId>project</artifactId> <version>1.0</version> <build> <sourceDirectory>C:\MVN\project\src\main\java</sourceDirectory> <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> <testSourceDirectory>C:\MVN\project\src\test\java</testSourceDirectory> <outputDirectory>C:\MVN\project\target\classes</outputDirectory> <testOutputDirectory>C:\MVN\project\target\test-classes</testOutputDirectory> <resources> <resource> <mergeId>resource-0</mergeId> <directory>C:\MVN\project\src\main\resources</directory> </resource> </resources> <testResources> <testResource> <mergeId>resource-1</mergeId> <directory>C:\MVN\project\src\test\resources</directory> </testResource> </testResources> <directory>C:\MVN\project\target</directory> <finalName>project-1.0</finalName> <pluginManagement> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-2</version> </plugin> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <version>2.0</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.4</version> </plugin> <plugin> <artifactId>maven-ear-plugin</artifactId> <version>2.3.1</version> </plugin> <plugin> <artifactId>maven-ejb-plugin</artifactId> <version>2.1</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.2</version> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.2</version> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <version>2.5</version> </plugin> <plugin> <artifactId>maven-plugin-plugin</artifactId> <version>2.4.3</version> </plugin> <plugin> <artifactId>maven-rar-plugin</artifactId> <version>2.2</version> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.0-beta-8</version> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.3</version> </plugin> <plugin> <artifactId>maven-site-plugin</artifactId> <version>2.0-beta-7</version> </plugin> <plugin> <artifactId>maven-source-plugin</artifactId> <version>2.0.4</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.3</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1-alpha-2</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-help-plugin</artifactId> <version>2.1.1</version> </plugin> </plugins> </build> <repositories> <repository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Maven Repository Switchboard</name> <url>http://repo1.maven.org/maven2</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <releases> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Maven Plugin Repository</name> <url>http://repo1.maven.org/maven2</url> </pluginRepository> </pluginRepositories> <reporting> <outputDirectory>C:\MVN\project\target/site</outputDirectory> </reporting> </project>

In the pom.xml above, you can see the default project source directory structure, output directory, required plugins, repositories, and report directories that Maven needs when executing goals.

Maven's pom.xml file does not need to be written manually.

Maven provides a large number of archetype plugins to create projects, including the project structure and pom.xml.


Detailed Explanation of POM Tags

The following is a categorized explanation of all important tags in pom.xml, covering core content such as project information, dependency management, build configuration, and environment settings.

Tags that all POM files must contain:modelVersion, groupId, artifactId, and version。

Tag Category Description Example/Optional values Whether required
Basic Information
<modelVersion> Project Structure POM model version 4.0.0 Yes
<groupId> Coordinates Organization identifier (reverse domain name) com.example Yes
<artifactId> Coordinates Project name my-project Yes
<version> Coordinates Project version 1.0.0-SNAPSHOT Yes
<packaging> Project type Packaging format jar/war/pom No (default jar)
<name> Meta information Project display name My Application no
<description> Meta information Project description A demo project no
<url> Meta information Project homepage URL https://example.com no
Dependency Management
<dependencies> Dependency Dependency list container Contains multiple<dependency> no
<dependency> Dependency Single dependency definition ContainsgroupIdand other sub-tags Optional
<scope> Dependency Dependency scope compile/test/provided/runtime No (default compile)
<optional> Dependency Whether optional dependency true/false No (default false)
<exclusions> Dependency Exclude transitive dependencies Contains<exclusion>List no
Build configuration
<build> Build Build configuration container Contains plugin/resource configurations, etc. no
<plugins> Build Plugin list container Contains multiple<plugin> no
<plugin> Build Single plugin definition Must specifygroupIdandartifactId Optional
<resources> Build Resource file configuration Definition<resource>Path no
<testResources> Build Test resource file configuration Similar<resources> no
<finalName> Build Final packaging file name my-app no
Environment configuration
<properties> Configuration Custom variable container Defines key-value pairs no
<java.version> Properties Java version variable 11/17wait no
<repositories> Repositories Custom remote repository list Contains<repository> no
<pluginRepositories> Repository Custom plugin repository Similar<repositories> no
Multi-module management
<modules> Modules Submodule list Contains multiple<module> Required for aggregator projects
<parent> Inherit Parent POM reference Must specify parent project coordinates Required for inherited projects
<dependencyManagement> Dependencies Centrally manage dependency versions Defines versions but does not introduce no
<profiles> Configuration Environment profile container Defines different environment configurations no
Other information
<licenses> Legal License information Contains<license> no
<developers> People Developer list Contains<developer> no
<contributors> People Contributor list Similar<developers> no
<issueManagement> Management Issue tracking system Defines issue system URL no
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd"> <!--Coordinates of the parent project. If a value for an element is not specified in the project, the corresponding value from the parent project is used as the default. The coordinates include group ID, artifact ID, and version.--> <parent> <!--The artifact identifier of the parent project being inherited--> <artifactId /> <!--The globally unique identifier of the parent project being inherited--> <groupId /> <!--The version of the parent project being inherited--> <version /> <!--The relative path to the pom.xml file of the parent project. The relative path allows you to select a different path. The default value is ../pom.xml. Maven first looks for the parent pom where the current project is being built, then at this location on the filesystem (the relativePath location), then in the local repository, and finally in the remote repository.--> <relativePath /> </parent> <!--Declares which POM model version the project descriptor follows. The version of the model itself changes very rarely, but it is still essential to ensure stability when Maven introduces new features or other model changes.--> <modelVersion>4.0.0</modelVersion> <!--The globally unique identifier of the project, usually using a fully qualified package name to distinguish this project from others. The path generated during the build is also derived from this; for example, com.mycompany.app generates the relative path: /com/mycompany/app--> <groupId>asia.banseon</groupId> <!--The identifier of the artifact, which together with the group ID uniquely identifies an artifact. In other words, you cannot have two different projects with the same artifact ID and group ID; within a particular group ID, the artifact ID must also be unique. An artifact is something produced or used by a project. Artifacts produced by Maven for a project include JARs, source code, binary releases, WARs, etc.--> <artifactId>banseon-maven2</artifactId> <!--The type of artifact produced by the project, e.g., jar, war, ear, pom. Plugins can create their own artifact types, so the ones listed earlier are not all artifact types.--> <packaging>jar</packaging> <!--The current version of the project, in the format: major version.minor version.incremental version-qualifier version number--> <version>1.0-SNAPSHOT</version> <!--The name of the project, used in Maven-generated documentation--> <name>banseon-maven</name> <!--The URL of the project's homepage, used in Maven-generated documentation--> <url>http://www.baidu.com/banseon</url> <!--The detailed description of the project, used in Maven-generated documentation. When this element can be described in HTML format (e.g., text in CDATA is ignored by the parser, so HTML tags can be included), plain text descriptions are discouraged. If you need to modify the index page of the generated web site, you should modify your own index page file rather than adjusting this document.--> <description>A maven project to study maven.</description> <!--Describes the prerequisites in the build environment of this project.--> <prerequisites> <!--The minimum version of Maven required to build this project or use this plugin--> <maven /> </prerequisites> <!--The name and URL of the project's issue management system (Bugzilla, Jira, Scarab, or any issue management system you like). In this example, it is jira.--> <issueManagement> <!--The name of the issue management system (e.g., jira),--> <system>jira</system> <!--The URL of the issue management system used by this project--> <url>http://jira.baidu.com/banseon</url> </issueManagement> <!--Project continuous integration information--> <ciManagement> <!--The name of the continuous integration system, e.g., continuum--> <system /> <!--The URL of the continuous integration system used by this project (if the continuous integration system has a web interface).--> <url /> <!--Configuration items for developers/users to be notified when the build completes. Includes notifiee information and notification conditions (error, failure, success, warning).--> <notifiers> <!--Configures a method by which users/developers are notified when the build is interrupted--> <notifier> <!--The channel through which notifications are sent--> <type /> <!--Whether to notify when an error occurs--> <sendOnError /> <!--Whether to notify when the build fails--> <sendOnFailure /> <!--Whether to notify when the build succeeds--> <sendOnSuccess /> <!--Whether to notify when a warning occurs--> <sendOnWarning /> <!--Deprecated. Where notifications are sent--> <address /> <!--Extension configuration item--> <configuration /> </notifier> </notifiers> </ciManagement> <!--The year the project was created, a 4-digit number. This value is needed when generating copyright information.--> <inceptionYear /> <!--Mailing list information related to the project--> <mailingLists> <!--This element describes all mailing lists related to the project. The automatically generated web site references this information.--> <mailingList> <!--The name of the mailing list--> <name>Demo</name> <!--The address or link for sending mail. If it is an email address, a mailto: link will be automatically created when generating documentation.--> <post>[email protected]</post> <!--The address or link for subscribing to the mailing list. If it is an email address, a mailto: link will be automatically created when generating documentation.--> <subscribe>[email protected]</subscribe> <!--The address or link for unsubscribing from the mailing list. If it is an email address, a mailto: link will be automatically created when generating documentation.--> <unsubscribe>[email protected]</unsubscribe> <!--The URL where you can browse mailing list messages--> <archive>http:/hi.baidu.com/banseon/demo/dev/</archive> </mailingList> </mailingLists> <!--The list of project developers--> <developers> <!--Information about a project developer--> <developer> <!--The unique identifier of the project developer in SCM--> <id>HELLO WORLD</id> <!--The full name of the project developer--> <name>banseon</name> <!--The email of the project developer--> <email>[email protected]</email> <!--The URL of the project developer's homepage--> <url /> <!--The roles the project developer plays in the project. The role element describes various roles.--> <roles> <role>Project Manager</role> <role>Architect</role> </roles> <!--The organization to which the project developer belongs--> <organization>demo</organization> <!--The URL of the organization to which the project developer belongs--> <organizationUrl>http://hi.baidu.com/banseon</organizationUrl> <!--Properties of the project developer, such as how instant messaging is handled, etc.--> <properties> <dept>No</dept> </properties> <!--The time zone of the project developer, an integer in the range -11 to 12.--> <timezone>-5</timezone> </developer> </developers> <!--The list of other contributors to the project--> <contributors> <!--Other contributors to the project. See developers/developer element--> <contributor> <name /> <email /> <url /> <organization /> <organizationUrl /> <roles /> <timezone /> <properties /> </contributor> </contributors> <!--This element describes the list of all licenses for the project. Only the project's license list should be listed, not the license list of dependency projects. If multiple licenses are listed, users can choose one of them rather than accepting all licenses.--> <licenses> <!--Describes the project's license. It is used to generate the license page of the project's web site. Some other reports and validations also use this element.--> <license> <!--The legal name used for the license--> <name>Apache 2</name> <!--The URL of the official license text page--> <url>http://www.baidu.com/banseon/LICENSE-2.0.txt</url> <!--The primary method of project distribution: repo, can be downloaded from the Maven repository; manual, the user must manually download and install dependencies--> <distribution>repo</distribution> <!--Supplementary information about the license--> <comments>A business-friendly OSS license</comments> </license> </licenses> <!--The SCM (Source Control Management) tag allows you to configure your code repository for use by the Maven web site and other plugins.--> <scm> <!--The SCM URL, which describes the repository and how to connect to it. For details, see the URL formats and list provided by SCMs. This connection is read-only.--> <connection> scm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk) </connection> <!--Used by developers, similar to the connection element. That is, this connection is not only read-only.--> <developerConnection> scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunk </developerConnection> <!--The tag of the current code, defaulting to HEAD during the development phase--> <tag /> <!--The URL pointing to the project's browsable SCM repository (e.g., ViewVC or Fisheye).--> <url>http://svn.baidu.com/banseon</url> </scm> <!--Describes various attributes of the organization to which the project belongs. Used in Maven-generated documentation.--> <organization> <!--The full name of the organization--> <name>demo</name> <!--The URL of the organization's homepage--> <url>http://www.baidu.com/banseon</url> </organization> <!--Information needed to build the project--> <build> <!--This element sets the project source directory. When the project is built, the build system compiles the source code in that directory. This path is relative to the pom.xml.--> <sourceDirectory /> <!--This element sets the project script source directory. This directory is different from the source directory: in most cases, the contents of this directory are copied to the output directory (because scripts are interpreted, not compiled).--> <scriptSourceDirectory /> <!--This element specifies the source directory used for unit tests of the project. When testing the project, the build system compiles the source code in that directory. This path is relative to pom.xml.--> <testSourceDirectory /> <!--The directory where compiled application class files are stored.--> <outputDirectory /> <!--The directory where compiled test class files are stored.--> <testOutputDirectory /> <!--Uses a set of build extensions from this project.--> <extensions> <!--Describes the build extensions that are used.--> <extension> <!--The groupId of the build extension.--> <groupId /> <!--The artifactId of the build extension.--> <artifactId /> <!--The version of the build extension.--> <version /> </extension> </extensions> <!--The default value when the project does not specify a goal (called a phase in Maven 2).--> <defaultGoal /> <!--This element describes a list of all resource paths related to the project, such as project-related property files. These resources are included in the final packaged file.--> <resources> <!--This element describes all resource paths related to the project or related to tests.--> <resource> <!--Describes the target path for the resource. This path is relative to the target/classes directory (e.g., ${project.build.outputDirectory}). For example, if you want the resource to be in a specific package (org.apache.maven.messages), you must set this element to org/apache/maven/messages. However, if you just want to place the resource in the source directory structure, you do not need this configuration.--> <targetPath /> <!--Whether to use parameter values instead of parameter names. The parameter values are taken from the properties element or from properties configured in files, which are listed in the filters element.--> <filtering /> <!--Describes the directory where resources are stored. This path is relative to the POM path.--> <directory /> <!--List of include patterns, e.g., **/*.xml.--> <includes /> <!--List of exclude patterns, e.g., **/*.xml.--> <excludes /> </resource> </resources> <!--This element describes all resource paths related to unit tests, such as property files related to unit tests.--> <testResources> <!--This element describes all resource paths related to tests. See the description of the build/resources/resource element.--> <testResource> <targetPath /> <filtering /> <directory /> <includes /> <excludes /> </testResource> </testResources> <!--The directory where all files generated by the build are stored.--> <directory /> <!--The file name of the produced artifact. The default value is ${artifactId}-${version}.--> <finalName /> <!--The list of filter property files used when filtering is enabled.--> <filters /> <!--Default plugin information that subprojects can reference. This plugin configuration is not resolved or bound to the lifecycle until it is referenced. Any local configuration for a given plugin overrides the configuration here.--> <pluginManagement> <!--List of plugins used.--> <plugins> <!--The plugin element contains information needed to describe a plugin.--> <plugin> <!--The groupId of the plugin in the repository.--> <groupId /> <!--The artifactId of the plugin in the repository.--> <artifactId /> <!--The version (or version range) of the plugin to be used.--> <version /> <!--Whether to download Maven extensions (such as packaging and type handlers) from this plugin. For performance reasons, this element is set to enabled only when downloading is truly necessary.--> <extensions /> <!--Configuration for executing a set of goals in the build lifecycle. Each goal may have different configuration.--> <executions> <!--The execution element contains information needed for the execution of a plugin.--> <execution> <!--The identifier of the execution goal, used to identify the goal in the build process, or to match execution goals that need to be merged during inheritance.--> <id /> <!--The build lifecycle phase to which the goal is bound. If omitted, the goal is bound to the default phase configured in the source data.--> <phase /> <!--The goal that is configured for execution.--> <goals /> <!--Whether the configuration is propagated to child POMs.--> <inherited /> <!--Configuration as a DOM object.--> <configuration /> </execution> </executions> <!--Additional dependencies required by the project to introduce the plugin.--> <dependencies> <!--See dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> <!--Whether any configuration is propagated to subprojects.--> <inherited /> <!--Configuration as a DOM object.--> <configuration /> </plugin> </plugins> </pluginManagement> <!--List of plugins used.--> <plugins> <!--See build/pluginManagement/plugins/plugin element.--> <plugin> <groupId /> <artifactId /> <version /> <extensions /> <executions> <execution> <id /> <phase /> <goals /> <inherited /> <configuration /> </execution> </executions> <dependencies> <!--See dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> <goals /> <inherited /> <configuration /> </plugin> </plugins> </build> <!--The project build profiles listed, which modify the build process if activated.--> <profiles> <!--Activates a build profile based on environment parameters or command-line parameters.--> <profile> <!--The unique identifier of the build profile. It is used for command-line activation as well as for merging profiles with the same identifier during inheritance.--> <id /> <!--The conditional logic that automatically triggers a profile. Activation is the key to turning on a profile. The power of a profile comes from its ability to automatically use certain specific values in certain environments; these environments are specified through the activation element. The activation element is not the only way to activate a profile.--> <activation> <!--A flag indicating whether the profile is active by default.--> <activeByDefault /> <!--The profile is activated when a matching JDK is detected. For example, 1.4 activates JDK 1.4, 1.4.0_2, while !1.4 activates all JDKs whose version does not start with 1.4.--> <jdk /> <!--The profile is activated when matching operating system properties are detected. The os element can define some operating system related properties.--> <os> <!--The name of the operating system that activates the profile.--> <name>Windows XP</name> <!--The family to which the operating system that activates the profile belongs (e.g., 'windows').--> <family>Windows</family> <!--The architecture of the operating system that activates the profile.--> <arch>x86</arch> <!--The version of the operating system that activates the profile.--> <version>5.1.2600</version> </os> <!--If Maven detects a property (whose value can be referenced in the POM via ${name}) that has the corresponding name and value, the profile will be activated. If the value field is empty, then the mere presence of the property name field activates the profile; otherwise, the property value field is matched in a case-sensitive manner.--> <property> <!--The name of the property that activates the profile.--> <name>mavenVersion</name> <!--The value of the property that activates the profile.--> <value>2.0.3</value> </property> <!--Provides a file name and activates the profile by detecting whether the file exists or does not exist. missing checks whether the file exists; if it does not exist, the profile is activated. On the other hand, exists checks whether the file exists; if it exists, the profile is activated.--> <file> <!--If the specified file exists, the profile is activated.--> <exists>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/ </exists> <!--If the specified file does not exist, the profile is activated.--> <missing>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/ </missing> </file> </activation> <!--Information needed to build the project. See the build element.--> <build> <defaultGoal /> <resources> <resource> <targetPath /> <filtering /> <directory /> <includes /> <excludes /> </resource> </resources> <testResources> <testResource> <targetPath /> <filtering /> <directory /> <includes /> <excludes /> </testResource> </testResources> <directory /> <finalName /> <filters /> <pluginManagement> <plugins> <!--See build/pluginManagement/plugins/plugin element.--> <plugin> <groupId /> <artifactId /> <version /> <extensions /> <executions> <execution> <id /> <phase /> <goals /> <inherited /> <configuration /> </execution> </executions> <dependencies> <!--See dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> <goals /> <inherited /> <configuration /> </plugin> </plugins> </pluginManagement> <plugins> <!--See build/pluginManagement/plugins/plugin element.--> <plugin> <groupId /> <artifactId /> <version /> <extensions /> <executions> <execution> <id /> <phase /> <goals /> <inherited /> <configuration /> </execution> </executions> <dependencies> <!--See dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> <goals /> <inherited /> <configuration /> </plugin> </plugins> </build> <!--Modules (sometimes called subprojects) are built as part of the project. Each listed module element is a relative path to the directory of that module.--> <modules /> <!--List of remote repositories for discovering dependencies and extensions.--> <repositories> <!--See repositories/repository element.--> <repository> <releases> <enabled /> <updatePolicy /> <checksumPolicy /> </releases> <snapshots> <enabled /> <updatePolicy /> <checksumPolicy /> </snapshots> <id /> <name /> <url /> <layout /> </repository> </repositories> <!--List of remote repositories for discovering plugins, which are used for builds and reporting.--> <pluginRepositories> <!--Contains information needed to connect to remote plugin repositories. See repositories/repository element.--> <pluginRepository> <releases> <enabled /> <updatePolicy /> <checksumPolicy /> </releases> <snapshots> <enabled /> <updatePolicy /> <checksumPolicy /> </snapshots> <id /> <name /> <url /> <layout /> </pluginRepository> </pluginRepositories> <!--This element describes all dependencies related to the project. These dependencies form individual links in the project build process. They are automatically downloaded from the repositories defined by the project. For more information, see the project dependency mechanism.--> <dependencies> <!--See dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> <!--Deprecated. Maven now ignores this element.--> <reports /> <!--This element includes specifications for generating reports using reporting plugins. When the user executes "mvn site", these reports will be run. Links to all reports can be seen in the page navigation bar. See the reporting element.--> <reporting> ...... </reporting> <!--See dependencyManagement element.--> <dependencyManagement> <dependencies> <!--See dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> </dependencyManagement> <!--See distributionManagement element.--> <distributionManagement> ...... </distributionManagement> <!--See properties element.--> <properties /> </profile> </profiles> <!--Modules (sometimes called subprojects) are built as part of the project. Each listed module element is a relative path to the directory of that module.--> <modules /> <!--List of remote repositories for discovering dependencies and extensions.--> <repositories> <!--Contains information needed to connect to remote repositories.--> <repository> <!--How to handle the download of release versions from the remote repository.--> <releases> <!--true or false indicates whether the repository is enabled for downloading a certain type of artifact (release, snapshot).--> <enabled /> <!--This element specifies how often updates occur. Maven compares the timestamps of the local POM and the remote POM. The options here are: always, daily (default), interval: X (where X is a time interval in minutes), or never.--> <updatePolicy /> <!--What to do when Maven fails to verify the artifact checksum file: ignore, fail, or warn.--> <checksumPolicy /> </releases> <!--How to handle downloading of snapshot versions from the remote repository. With the two configuration groups, releases and snapshots, the POM can adopt different strategies for each type of artifact in each individual repository. For example, someone might decide to enable support for downloading snapshot versions only for development purposes. See repositories/repository/releases element.--> <snapshots> <enabled /> <updatePolicy /> <checksumPolicy /> </snapshots> <!--The unique identifier of the remote repository. It can be used to match remote repositories configured in the settings.xml file.--> <id>banseon-repository-proxy</id> <!--Remote repository name--> <name>banseon-repository-proxy</name> <!--Remote repository URL, in the form of protocol://hostname/path--> <url>http://192.168.1.169:9999/repository/</url> <!--The repository layout type used to locate and sort artifacts - can be default (default) or legacy (legacy). Maven 2 provides a default layout for its repositories; however, Maven 1.x has a different layout. We can use this element to specify whether the layout is default (default) or legacy (legacy).--> <layout>default</layout> </repository> </repositories> <!--A list of remote repositories used to discover plugins, which are used for builds and reports--> <pluginRepositories> <!--Contains information needed to connect to remote plugin repositories. See the repositories/repository element.--> <pluginRepository> ...... </pluginRepository> </pluginRepositories> <!--This element describes all dependencies related to the project. These dependencies form the individual steps in the project build process. They are automatically downloaded from the repositories defined in the project. For more information, see the project dependency mechanism.--> <dependencies> <dependency> <!--The group ID of the dependency--> <groupId>org.apache.maven</groupId> <!--The artifact ID of the dependency--> <artifactId>maven-artifact</artifactId> <!--The version number of the dependency. In Maven 2, it can also be configured as a version range.--> <version>3.8.1</version> <!--Dependency type, default type is jar. It usually indicates the file extension of the dependency, but there are exceptions. A type can be mapped to another extension or classifier. Types often correspond to the packaging method used, although there are exceptions. Some examples of types: jar, war, ejb-client, and test-jar. If extensions is set to true, new types can be defined in the plugin. So the preceding examples of types are not complete.--> <type>jar</type> <!--The classifier of the dependency. The classifier distinguishes artifacts that belong to the same POM but are built in different ways. The classifier name is appended to the version number in the filename. For example, if you want to build two separate JAR artifacts, one using the Java 1.4 compiler and the other using the Java 6 compiler, you can use classifiers to generate two separate JAR artifacts.--> <classifier></classifier> <!--Dependency scope. Helps determine which artifacts are included during the project release process. For details, refer to the dependency mechanism. - compile: default scope, used for compilation - provided: similar to compile, but indicates that you expect the JDK or container to provide it, similar to classpath - runtime: needed for execution - test: used for test tasks - system: requires the corresponding elements to be provided externally. Obtained via systemPath - systemPath: only used when the scope is system. Provides the corresponding path - optional: when the project itself is depended on, marks whether the dependency is transitive. Used for transitive dependencies.--> <scope>test</scope> <!--Only for use with the system scope. Note that the use of this element is discouraged and the element may be overridden in new versions. This element specifies a filesystem path for the dependency. An absolute path is required rather than a relative path. It is recommended to use properties to match absolute paths, e.g. ${java.home}.--> <systemPath></systemPath> <!--When calculating transitive dependencies, lists the set of excluded dependency artifacts from the dependency artifact list. That is, it tells Maven that you only depend on the specified project, not on that project's dependencies. This element is mainly used to resolve version conflicts.--> <exclusions> <exclusion> <artifactId>spring-core</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> <!--Optional dependency. If you declare C as an optional dependency in project B, then projects that depend on B (such as project A) need to explicitly reference the dependency on C. Optional dependencies block the transitivity of dependencies.--> <optional>true</optional> </dependency> </dependencies> <!--Deprecated. Maven currently ignores this element.--> <reports></reports> <!--This element describes the specifications for generating reports using reporting plugins. These reports run when the user executes "mvn site". Links to all reports can be seen in the page navigation bar.--> <reporting> <!--If true, the site does not include the default reports. This includes reports in the "Project Information" menu.--> <excludeDefaults /> <!--Where all generated reports are placed. The default value is ${project.build.directory}/site.--> <outputDirectory /> <!--The reporting plugins used and their configuration.--> <plugins> <!--The plugin element contains information needed to describe the reporting plugin.--> <plugin> <!--The group ID of the reporting plugin in the repository.--> <groupId /> <!--The artifact ID of the reporting plugin in the repository.--> <artifactId /> <!--The version (or version range) of the reporting plugin used.--> <version /> <!--Whether any configuration is propagated to child projects.--> <inherited /> <!--The configuration of the reporting plugin.--> <configuration /> <!--Multiple specifications of a set of reports, each specification may have different configuration. A specification (report set) corresponds to an execution goal. For example, there are reports 1, 2, 3, 4, 5, 6, 7, 8, and 9. Reports 1, 2, and 5 form report set A, corresponding to one execution goal. Reports 2, 5, and 8 form report set B, corresponding to another execution goal.--> <reportSets> <!--Represents a set of reports, along with the configuration that produces the set.--> <reportSet> <!--The unique identifier of the report set, used in POM inheritance.--> <id /> <!--The configuration of the reports used when generating the report set.--> <configuration /> <!--Whether the configuration is inherited by child POMs.--> <inherited /> <!--Which reports are used in this set.--> <reports /> </reportSet> </reportSets> </plugin> </plugins> </reporting> <!--Default dependency information inherited by all child projects from this project. This part of the dependency information is not resolved immediately, but when a child project declares a dependency (which must describe the group ID and artifact ID), if some information other than the group ID and artifact ID is not described, the dependency here is matched via the group ID and artifact ID, and the dependency information here is used.--> <dependencyManagement> <dependencies> <!--See the dependencies/dependency element.--> <dependency> ...... </dependency> </dependencies> </dependencyManagement> <!--Project distribution information, indicating the location to publish to after executing mvn deploy. With this information, the website can be deployed to a remote server or artifacts can be deployed to a remote repository.--> <distributionManagement> <!--Information needed to deploy the artifacts produced by the project to a remote repository.--> <repository> <!--Should a unique version number (consisting of a timestamp and build sequence number) be assigned to the snapshot, or should the same version number be used each time? See the repositories/repository element.--> <uniqueVersion /> <id>banseon-maven2</id> <name>banseon maven2</name> <url>file://${basedir}/target/deploy</url> <layout /> </repository> <!--Where should the snapshot of the artifact be deployed? If this element is not configured, it is deployed by default to the repository configured in the repository element. See the distributionManagement/repository element.--> <snapshotRepository> <uniqueVersion /> <id>banseon-maven2</id> <name>Banseon-maven2 Snapshot Repository</name> <url>scp://svn.baidu.com/banseon:/usr/local/maven-snapshot</url> <layout /> </snapshotRepository> <!--Information needed to deploy the project's website.--> <site> <!--The unique identifier of the deployment location, used to match the configuration in the site and settings.xml file.--> <id>banseon-site</id> <!--The name of the deployment location.--> <name>business api website</name> <!--The URL of the deployment location, in the form of protocol://hostname/path.--> <url> scp://svn.baidu.com/banseon:/var/www/localhost/banseon-web </url> </site> <!--The URL of the project download page. If this element is not present, users should refer to the homepage. The reason for using this element is to help locate artifacts that are not in the repository (due to license restrictions).--> <downloadUrl /> <!--If the artifact has a new group ID and artifact ID (the artifact has been moved to a new location), the relocation information for the artifact is listed here.--> <relocation> <!--The new group ID of the artifact.--> <groupId /> <!--The new artifact ID of the artifact.--> <artifactId /> <!--The new version number of the artifact.--> <version /> <!--Extra information shown to the user about the move, such as the reason.--> <message /> </relocation> <!--Gives the status of the artifact in the remote repository. This element must not be set in a local project because it is automatically updated by tools. Valid values are: none (default), converted (converted from a Maven 1 POM by the repository administrator), partner (synchronized directly from a partner Maven 2 repository), deployed (deployed from a Maven 2 instance), verified (verified as correct and final).--> <status /> </distributionManagement> <!--Substitutes a value for a name. Properties can be used throughout the POM, and can also serve as activation conditions (see the description of the activation element in the settings.xml configuration file). The format is <name>value</name>.--> <properties /> </project>
Other extensions