Maven---> Learning tips--->maven configuration file pom.xml

Source: Internet
Author: User

1. Overview:

MAVEN is managing the jar package through its configuration file Pom.xml, so it is necessary to understand the Pom.xml file structure, and this article describes pom.xml related knowledge.

2. References:

1)Maven official website Documentation,pom (English document)

            On this website, documentation describes the following:

              • What is a POM?
              • Super POM Parent Pom.xml, the pom.xml of the MAVEN project you created will actually automatically inherit super Pom.xml, which automatically inherits the default configuration information defined in Superpom.xml
              • Minimal POM
              • Project Inheritance Project inheritance
                • Example 1
                • Example 2
                Project Aggregation Project Aggregation
                • Example 3
                • Example 4
              • Project Inheritance vs Project Aggregation
                • Example 5
              • Project interpolation and variables engineering interpolation and variables
                • Available Variables   
3. Learning experience: 3.1) Basic knowledge points
          • Pom:project object Model, A Project Object Model or POM is the fundamental unit of work in Maven,it is a XML file
          • Super POM: The Super Pom is Maven ' s default Pom. All POMs extend the Super Pom unless explicitly set, meaning the configuration specified in the Super Pom are inherited by  The POMs created for your projects. For the contents of the Superpom.xml file, see MAVEN official website related documentation: specific content of different versions of Maven Superpom.xml (see Super Pom section in this document)
          • Pom.xml content:
            • Pom.xml can define your project's basic information (such as the project version, description, developers, mailing lists)
            • You can configure the relevant plugin plugins, (Maven plugin, such as package plugin, Javadoc plugin ...).
            • You can configure the project dependencies (that is, the three-party jar packages, library files, etc.) that your project relies on.
            • You can also define the directory structure of your entire project (for example, the compilation results of configuration Src/main/java are stored in the Target/classes directory, and the results of the Src/test/java files are stored under the Target/test-classes folder). These things have default value in Super Pom.xml.
            • Summary: You can edit several of the following in your project's Pom.xml

                • Dependencies
                • Developers and contributors
                • Plugin lists (including reports)
                • Plugin executions with matching IDs
                • Plugin configuration
                • Resources
          •   

     

3.2) How to write the Pom.xml of your project
          • Step1, Understand that your pom.xml will automatically inherit superpom.xml, meaning that your pom.xml will actually automatically inherit some of Maven's default configurations, such as your project will be packaged as a jar package by default, and the associated plugins for Maven, such as Javadoc, are integrated by default. A plugin ... (See the details of the Superpom.xml file for more default configurations).
              • Note: If The configuration details is not specified, Maven would use their defaults. (That is, the relevant configuration in Superpom.xml) 
              • Your project can inherit other pom.xml (such as a custom pom.xml) in addition to inheriting superpom.xml.
          • Step2,Write your pom.xml, first to have the most basic configuration information
              • The minimum requirement for a POM is the following:

                  • Project Root
                  • Modelversion-should BES set to 4.0.0
                  • Groupid-the ID of the project ' s group.
                  • Artifactid-the ID of the artifact (project)
                  • Version-the version of the artifact under the specified group

                Here's an example:

                <Project><modelversion>4.0.0</modelversion><groupId>Com.mycompany.app</groupId><Artifactid>My-app</Artifactid><version>1</version></Project>
            • Step3, after the STEP2, your project's basic information has been defined, the following can be further progress on the project in the Pom.xml to configure other configurable information
                •     

Maven---> Learning tips--->maven configuration file pom.xml

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.