Introduction to the maven pom File

Source: Internet
Author: User

From: http://www.cnblogs.com/ericsun/archive/2011/10/17/2215311.html

Pom is the abbreviation of the Project object model. The following describes the explanation of POM in Baidu encyclopedia.

Definition

Maven is a project-centered design. Pom is Maven's description of a single project. Maven is useless without pom -- Pom is the core of Maven. Is implemented by POM and drives this construction method described by model.

Pom example

The following pom example is a script that may be used to build and test a project. A pom is an XML document and looks similar to the following example:

<project>  <modelVersion>4.0.0</modelVersion>  <groupId>com.mycompany.app</groupId>  <artifactId>my-app</artifactId>  <packaging>jar</packaging>  <version>1.0-SNAPSHOT</version>  <dependencies>      <dependency>          <groupId>junit</groupId>          <artifactId>junit</artifactId>          <version>3.8.1</version>          <scope>test</scope>      </dependency>  </dependencies></project>

This pom script allows you to compile, test, and generate basic documents. You may ask how the 15 lines of code in this area are implemented. In fact, this is a very good and basic question. The answer lies in Maven's concealed call to its super POM (the parent script of all pom scripts.

Rules

The Maven pom document contains all the default rules encouraged by Maven, which is similar to the java. Lang. Object object in the Java language.

In Java, all objects are sub-objects of Java. Lang. Object. Similarly, in Maven, all pom are also a sub-script of super pom. At first glance, this super pom may make you feel terrible. If you are interested in learning about it, see Appendix B. The most important thing to remember is that super pom contains important information, so you do not have to repeat this information when creating a pom.

Contains elements

A pom contains all the important information about your project. The pom example provided previously is very simple, but it still shows some key elements contained in a pom.

Project: The top-level element in all pom files, that is, the root element.

Modelversion: This required element describes the model version used by this pom. The version of the model itself is rarely changed. Despite this, it is still essential to ensure stability when Maven introduces new features or other model changes.

Groupid: This element indicates the unique identifier of the Organization that creates the project. Groupid is one of the core Key Identifiers of a project. It is based on the complete domain name of the organization.

Artifactid: the unique basic name of the main project of the project. A typical Maven-generated project name is in the following format: <artifactid>-<version>. <extension>. Other parts, such as the source package, also use artifactid as part of their names. Packaging: indicates the package type (jar, war, ear, etc.) used in this project ). This not only means to package jar, war, and ear, but also indicates a specific lifecycle as part of the build process. This lifecycle is a topic, which will be mentioned later in this chapter. Now, remember that the selected project package plays the role of custom build lifecycle. The default value of this element is jar, so you do not need to specify it in most cases.

Version: indicates the version of the project. MAVEN is very helpful for version management. You will often see a version of snapshot, indicating the different statuses of the project in development.

Name: The project display name, which is often used in Maven-generated documents. During the building process, it is used as a dependency for your project or other projects.

URL: the website URL of the project.

Description: project description.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.