[TOC]
# pom.xml 常用元素介紹
```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--指定了當前pom的版本-->
<modelVersion>4.0.0</modelVersion>
<!--坐標信息 start-->
<groupId>反寫的公司網址+項目名</groupId> <!--主項目標識-->
<artifactId>項目名+模塊名</artifactId>
<!--第一個0表示大版本號
第二個0表示分支版本號
第三個0標識小版本號
0.0.1SNAPSHOT
snapshot快照
alpha內測
beta公測
Release穩定
GA正式發布
-->
<version></version>
<!--打包方式:默認是jar
war zip pom
-->
<packaging></packaging>
<!--坐標信息 end-->
<!--項目描述名-->
<name>hi</name>
<!--項目地址-->
<url>http://maven.apache.org</url>
<!--項目描述-->
<description></description>
<!--開發人員列表-->
<developers></developers>
<!--許可證信息-->
<license></license>
<!--組織信息-->
<organization></organization>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!--依賴列表-->
<dependencies>
<!--依賴項-->
<dependency>
<!--項目坐標 start-->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type></type>
<scope>test</scope><!--指依賴范圍(只在依賴的范圍內有用,PS:junit如果此處為test,則只在測試的依賴范圍內有用,如在主代碼引用junit類則報錯)-->
<!--設置依賴是否可選,默認是false(子項依賴繼承),如為true子項必須顯示引入該依賴-->
<optional></optional>
<!--排除依賴傳遞列表-->
<exclusions>
<exclusion></exclusion>
</exclusions>
<!--項目坐標 end-->
</dependency>
</dependencies>
<!--依賴的管理-->
<!--不會運行,即不會調用到依賴中
一般定義在父模塊中,供子模塊調用
-->
<dependencyManagement>
<dependencies>
<dependency></dependency>
</dependencies>
</dependencyManagement>
<!--對構建行為提供相應的支持-->
<build>
<!--插件列表-->
<plugins>
<plugin>
<!--指定坐標-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- 一般在子模塊中指定所繼承的父模塊 -->
<!--子模塊對父模塊的繼承-->
<parent></parent>
<!--聚合多個模塊進行編譯,可多個子項-->
<modules>
<module></module>
</modules>
</project>
```