modelVersion 制定当前pom的版本
groupId 反写公司网址+项目名
artifactId 项目名+模块名
version 版本号
packaging 打包方式
name 项目描述名
url 项目地址
description 项目描述
dependencies 依赖列表
dependency
groupId
artifactId
version
scope 依赖范围
optional 设置依赖是否可选
exclusions 排除依赖传递列表
exclusion
groupId
artifactId
version
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<!-- 只在编译和测试中运行 -->
<scope>provided</scope>
</dependency>
</dependencies>
scope 依赖范围
参数:
compile 默认的范围,编译测试运行都有效
provided 在编译和测试有效
runtime 在测试和运行时有效
test 只在测试时有效
system 与本机系统相关联,可移植性差
import 导入的范围,只使用在dependencyManagement中,表示从其他的pom中导入dependecy的配置
依赖继承:A继承B,B继承C。则A中会存放B和C的jar,但可以用exclusion排除C的jar
graph LR
A-->B
B-->C
依赖冲突:短路优先;若路径长度相同,则谁先声明,先解析谁
dependencyManagement 依赖管理,声明依赖(并不会在该项目中使用)
dependencies
dependency
build 构建设置
plugins 插件列表
plugin
groupId
artifactId
version
executions
execution
phase
goals
goal
<build>
<finalName>WebDemo</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8888</port>
<uriEncoding>UTF-8</uriEncoding>
<url>http://localhost:8888/WebDemo/</url>
<server>tomcat6</server>
</configuration>
<executions>
<execution>
<!-- 在打包成功后使用tomcat:run来运行tomcat服务 -->
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
parent 继承
聚合
modules 模块列表
module
继承