简介:

什么是POM?

POM是项目对象模型(Project Object Model)的简称,它是Maven项目中的文件,使用XML表示,名称叫做pom.xml。在Maven中,当谈到Project的时候,不仅仅是一堆包含代码的文件。一个Project往往包含一个配置文件,包括了与开发者有关的,缺陷跟踪系统,组织与许可,项目的URL,项目依赖,以及其他。它包含了所有与这个项目相关的东西。事实上,在Maven世界中,project可以什么都没有,甚至没有代码,但是必须包含pom.xml文件。

概览

下面是一个POM项目中的pom.xml文件中包含的元素。注意,其中的modelVersion是4.0.0,这是当前仅有的可以被Maven2&3同时支持的POM版本,它是必须的。

 1 <project xmlns="http://maven.apache.org/POM/4.0.0"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5 <modelVersion>4.0.0</modelVersion>
6
7 <!-- 基本设置 -->
8 <groupId>...</groupId>
9 <artifactId>...</artifactId>
10 <version>...</version>
11 <packaging>...</packaging>
12 <dependencies>...</dependencies>
13 <parent>...</parent>
14 <dependencyManagement>...</dependencyManagement>
15 <modules>...</modules>
16 <properties>...</properties>
17
18 <!-- 构建过程的设置 -->
19 <build>...</build>
20 <reporting>...</reporting>
21
22 <!-- 项目信息设置 -->
23 <name>...</name>
24 <description>...</description>
25 <url>...</url>
26 <inceptionYear>...</inceptionYear>
27 <licenses>...</licenses>
28 <organization>...</organization>
29 <developers>...</developers>
30 <contributors>...</contributors>
31
32 <!-- 环境设置 -->
33 <issueManagement>...</issueManagement>
34 <ciManagement>...</ciManagement>
35 <mailingLists>...</mailingLists>
36 <scm>...</scm>
37 <prerequisites>...</prerequisites>
38 <repositories>...</repositories>
39 <pluginRepositories>...</pluginRepositories>
40 <distributionManagement>...</distributionManagement>
41 <profiles>...</profiles>
42 </project>

基本的设置:

POM包含了一个project所需要的所有信息,当然也就包含了构建过程中所需要的插件的配置信息,事实上,这里申明了"who","what",和"where",然而构建生命周期(build lifecycle)s中说的是"when"和"how"。这并不是说POM并能影响生命周期的过程-事实上它可以。例如,配置一个可以嵌入ant任务到POM的mavem-antrun-plugin。它基本上就是一个声明。就像build.xml告诉ant当运行时它该做什么一样,一个POM申明了它自己的配置。如果外力迫使生命周期跳过了ant插件的执行,这并不影响那些已经执行过的插件产生的效果。这一点和build.xml不一样。

1 <project xmlns="http://maven.apache.org/POM/4.0.0"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5 <modelVersion>4.0.0</modelVersion>
6 <groupId>org.codehaus.mojo</groupId>
7 <artifactId>my-project</artifactId>
8 <version>1.0</version>
9 </project>

Maven坐标

上面的POM定义的是Maven2&3都承认的最小部分。groupId:artifactId:version是必须的字段(尽管在继承中groupId和version不需要明确指出)。这三个字段就像地址和邮戳,它标记了仓库中的特定位置,就像Maven projects的坐标系统一样

Maven的配置文件pom.xml的更多相关文章

  1. maven全局配置文件settings.xml详解

    概要 settings.xml有什么用? 如果在Eclipse中使用过Maven插件,想必会有这个经验:配置settings.xml文件的路径. settings.xml文件是干什么的,为什么要配置它 ...

  2. 【转】maven核心,pom.xml详解

    感谢如下博主: http://www.cnblogs.com/qq78292959/p/3711501.html maven核心,pom.xml详解 什么是pom?    pom作为项目对象模型.通过 ...

  3. [转]maven全局配置文件settings.xml详解

    概要 settings.xml有什么用? 如果在Eclipse中使用过Maven插件,想必会有这个经验:配置settings.xml文件的路径. Paste_Image.png settings.xm ...

  4. [转]Maven 全局配置文件settings.xml详解

    原文地址:https://www.jianshu.com/p/110d897a5442 概要 settings.xml有什么用? 如果在Eclipse中使用过Maven插件,想必会有这个经验:配置se ...

  5. Maven的配置文件-settings.xml内容分解

    本文转载:https://www.cnblogs.com/jingmoxukong/p/6050172.html 概要 settings.xml有什么用? 如果在Eclipse中使用过Maven插件, ...

  6. Maven全局配置文件settings.xml详解(转)

    Maven全局配置文件settings.xml详解   目录 一.概要 1.settings.xml的作用2.settings.xml文件位置3.配置的优先级 二.settings.xml元素详解 1 ...

  7. IDEA Maven project: 'xxx/pom.xml' already exists in VFS

    Failed to create a Maven project: 'xxx/pom.xml' already exists in VFS idea创建项目后,发现项目有问题,删除后重新创建,提示错误 ...

  8. Maven项目的pom.xml配置文件格式初识

    Maven项目 有pom.xml文件的项目就已经是一个maven项目了,但是还没有被maven托管,我们需要将该项目添加为maven项目 <project xmlns="http:// ...

  9. 创建maven项目时pom.xml报错的解决方法

    创建maven项目时pom.xml时: 出现如下报错信息: Failure to transfer commons-lang:commons-lang:jar:2.1 from https://rep ...

随机推荐

  1. Golang的Semicolons

    Semicolons The formal grammar uses semicolons ";" as terminators in a number of production ...

  2. 不靠谱的Paypal及海外网站

    昨天因为报名参加某个比赛,需要用到Paypal付款,整整折腾了我一个小时.我先是使用自己的银行储蓄卡,到最后一步需要银行确认,提示我需要安装个插件才能输入密码.安装完插件后需要重启浏览器,整个流程又要 ...

  3. java数据结构和算法------快速排序

    package iYou.neugle.sort; public class Quick_sort { public static void QuickSort(double[] array, int ...

  4. R语言实战读书笔记1—语言介绍

    第一章 语言介绍 1.1 典型的数据分析步骤 1.2 获取帮助 help.start() help("which") help.search("which") ...

  5. java 参数化类型

    package com.gxf.collection; import java.util.LinkedList; public class TestForT<T> { private Li ...

  6. c++函数内部声明函数,在函数外面实现函数是可以的

    这个具体有什么用我也不大清楚,只知道可以这样 #include <iostream> //#include "header1.h" using namespace st ...

  7. 深入理解CSS3 animation的steps

    在应用 CSS3 渐变/动画时,有个控制时间的属性 <timing-function> .它的取值中除了常用到的三次贝塞尔曲线以外,还有个让人比较困惑的 steps() 函数. steps ...

  8. js 完成对图片的等比例缩放的方法

    /* 重新按比例设置 页面上对应图片的长和高, */ function resetImgSize(id,imgWidth,imgHeight,posWidth,posHeight) { var wid ...

  9. 22、DDMS(转载)

    本文是转载,出处为http://www.xuebuyuan.com/1291595.html 如需删除本文,请私信我,谢谢 DDMS DDMS是一款Google* 提供的应用,可作为独立的工具运行,也 ...

  10. shell中的比较语句

    Linux比较字符串.判断文件是否存在及是否可读等,通常用"[]"来表示条件测试. 注意:这里的空格很重要.要确保方括号的空格.笔者就曾因为空格缺少或位置不对,而浪费好多宝贵的时间 ...