学习Maven POM

什么是POM

POM stands for “Project Object Model”.It is an XML representation of a Maven project held in a file named pom.xml.

Maven Coordinates

groupId:artifactId:version是必须字段

groupId:artifactId:packaging:classifier:version可选

groupId:类似包名,例如:org.codehaus.mojo

artifactId:项目名称

packaging:打包方式,默认是jar。如果设置成war,就是用<packaging>war</packaging>

version:项目版本号

classifier:

项目关系(POM Relationships)

项目关系包括:依赖(传递依赖)、继承和组合

Dependencies

POM的基础是依赖表。

Exclusions

告诉maven,这个依赖不进行传递。也就是说这个是当前引用,不传递给上层项目。

Inheritance

The elements in the parent POM that are inherited by its children are:

  • dependencies
  • developers and contributors
  • plugin lists
  • reports lists
  • plugin executions with matching ids
  • plugin configuration

Aggregation (or Multi-Module)

<modules>
    <module>my-project</module>
    <module>another-project</module>
  </modules>
属性(Properties)
访问方式:${X}
使用5中方式来访问:
1. 环境变量——env.X
例如:${env.PATH}访问环境变量中的PATH
2. project.x
pom文件中相关的值。例如<project><version>1.0</version></project> is accessible via ${project.version}.
3. settings.x
settings.xml文件中相关的值。例如:<settings><offline>false</offline></settings> is accessible via ${settings.offline}.
4. Java系统属性
${java.home}
5. x
POM中<properties />元素的值。例如<properties><someVar>value</someVar></properies>—>${someVar}
二、构建设置
build reporting
参考:
http://maven.apache.org/pom.html

Configuring the Jetty Maven Plugin

原文地址:https://www.cnblogs.com/javawer/p/3988624.html