什么是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>