Maven---pom.xml详解

1.什么是pom?

pom全称(Project Object Model )顾名思义,pom是项目对象模型,同时是Maven的工作的基本单位。这是一个XML文件,包含由Maven用来建造工程项目和配置的详细信息。它包含了大多数项目的默认值。

POM在Maven1叫project.xml, 在Maven 2之后改名为pom.xml。可以在POM中指定的一些配置是项目依赖项、可执行的插件或目标、构建概要文件等。还可以指定其他信息,如项目版本、描述、开发人员、邮件列表等。

2.Super POM

Super POM是Maven默认的POM,所有的pom文件都继承于这个文件

3.Minimal POM

Minimal POM是最小的POM文件,需要包含:

  • project root
  • modelVersion - should be 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
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
</project>

一个pom文件需要包括groupId,artifactId,version

4.Project Inheritance(项目继承结构)

POM文件的元素主要有以下分类

  • dependencies
  • developers and contributors
  • plugin lists (including reports)
  • plugin executions with matching ids
  • plugin configuration
  • resources

5.Project Aggregation(项目聚集结构)

与 Project Inheritance(项目继承结构)不同的是,Project Aggregation(项目聚集结构)直接从父POM指定模块,使用这种结构,你必须:

把父POMs的值改成“pom”,

在父POMs指定后代POMs的目录

原文地址:https://www.cnblogs.com/umrx/p/7746645.html