什么是pom文件_什么是POM?

什么是pom文件

什么是POM? (What is POM?)

The easiest way to describe a POM in a maven project is, it is nothing but the core element of any maven project. Basically any maven project consists of one configurable file called pom.xml, which stands for the abbreviation Project Object Model. This pom.xml will always be located in the root directory of any maven project. This file represents the very basic and fundamental unit in maven.

描述Maven项目中POM的最简单方法是,它不过是任何Maven项目的核心元素。 基本上,任何Maven项目都包含一个名为pom.xml的可配置文件,该文件代表缩写Project Object Model 。 此pom.xml将始终位于任何maven项目的根目录中。 该文件表示maven中非常基本的单元。

The pom.xml basically contains the information related to the project which is built or to be built in. It contains all the necessary information about the configuration details, dependencies included and plug-ins included in the project. In simple, it contains the details of the build life cycle of a project.

pom.xml基本上包含与已构建或将要构建的项目相关的信息。它包含有关配置详细信息,项目中包括的依赖项和插件的所有必要信息。 简单来说,它包含项目的构建生命周期的详细信息。

Below are some of the configurations that can be handled in the pom.xml file :

以下是pom.xml文件中可以处理的一些配置:

  • Dependencies used in the projects (Jar files)

    项目中使用的依赖项(Jar文件)
  • Plugins used (report plugin)

    使用的插件(报告插件)
  • Project version

    项目版本
  • Developers involved in the project

    参与项目的开发人员
  • Mailing list

    邮件列表
  • Reporting

    报告中
  • Build profiles

    构建配置文件

样本Pom.xml文件 (Sample Pom.xml File)

A typical pom.xml of simple java project will look like as shown in the below figure.

简单Java项目的典型pom.xml如下图所示。

什么是pom文件_什么是POM?

A pom.xml will always start with the root element called <project> under which all the other required configurations will be made. Developers should ensure to define the below list of elements which are known as maven co-ordinates before defining a pom.xml file:

pom.xml始终以称为<project>的根元素开头,在该根元素下将进行所有其他所需的配置。 开发人员应确保在定义pom.xml文件之前定义以下称为maven坐标的元素的列表:

  1. groupId - as the name itself shows that this is an id which is unique for any project in an organization.groupId-顾名思义,这表示该ID对于组织中的任何项目都是唯一的。
  2. artifactId - Even though the name says as "id", this is basically defines the name of any project.artifactId-即使名称表示为“ id”,这基本上也定义了任何项目的名称。
  3. version - This element is used to derive the version of any project in order to classify the versions as and when the major changes/implementations are carried during the development phase of a project.版本 -此元素用于派生任何项目的版本,以便在项目的开发阶段进行主要更改/实施时以及对版本进行分类时使用。

Whenever it comes for executing a task for a project, maven scans through the entries made in the pom. Xml file. This will enable the maven to read all the configurations made, build profiles defined, repositories configured and all other important details and then executes the task accordingly.

每当执行项目任务时,maven都会扫描pom中输入的内容。 Xml文件。 这将使Maven能够读取所做的所有配置,定义的构建配置文件,配置的存储库以及所有其他重要细节,然后相应地执行任务。

NOTE : Actually pom.xml was earlier used in the name of project.xml in maven 1. As the maven 2 version was introduced, this was renamed to pom.xml

注意:实际上,在maven 1中以前以pom.xml的名义使用了project.xml。随着maven 2版本的引入,它被重命名为pom.xml。

超级POM (Super POM)

All the maven projects pom.xml files always extends the super pom.xml file. This super pom.xml basically defines a set of default configurations which is shared and used by all the maven projects. This super pom.xml is not required to be written by the developers. This will come as a default one with the maven installation.

所有的Maven项目pom.xml文件始终会扩展super pom.xml文件。 这个超级pom.xml基本上定义了一组默认配置,这些配置由所有maven项目共享和使用。 此超级pom.xml不需要由开发人员编写。 这将默认安装在Maven中。

A typical super pom.xml can be found in the attached file. Click on th link below to download.

在附件中可以找到典型的super pom.xml。 点击下面的链接进行下载。

Download Super POM Xml file

下载Super POM Xml文件

Maven的目标 (Goals in Maven)

Goal in maven is nothing but a particular task which leads to the compiling, building and managing of a project. A goal in maven can be associated to zero or more build phases. Only thing that matters is the order of the goals defined for a given project in pom.xml. Because, the order of execution is completely dependent on the order of the goals defined.

Maven中的目标不过是导致项目的编译,构建和管理的特定任务。 Maven中的目标可以与零个或多个构建阶段相关联。 唯一重要的是在pom.xml中为给定项目定义的目标的顺序。 因为,执行顺序完全取决于所定义目标的顺序。

Download Maven Goals Xml file

下载Maven Goals Xml文件

翻译自: https://www.studytonight.com/maven/pom-in-maven

什么是pom文件