parent
<parent>
<artifactId>xxx</artifactId>
<groupId>xxx</groupId>
<version>xxx</version>
<relativePath>xxx</relativePath>
</parent>
- 父项目的pom.xml文件的相对路径,默认值是…/pom.xml。
Maven首先在构建寻找父项目的pom
- 当前项目的地方
- 文件系统的这个位置(relativePath位置)
- 本地仓库
- 远程仓库寻找父项目的pom
Maven生成构件
<modelVersion> 4.0.0 </modelVersion>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<packaging> jar </packaging>
<!-- 项目当前版本,格式为:主版本.次版本.增量版本-限定版本号 -->
<version> 1.0-SNAPSHOT </version>
<name> xxx-maven </name>
<!-- 项目主页的URL, Maven产生的文档用 -->
<url> http://maven.apache.org </url>
Maven的最低版本要求
<prerequisites>
<maven></maven>
</prerequisites>
问题管理系统
ciManagement notifiers
项目创建年份,4位数字。当产生版权信息时需要使用这个值 inceptionYear
项目开发者 developers
项目的其他贡献者 contributors
项目所有License列表 licenses
build
<build>
<sourceDirectory>源码目录</sourceDirectory>
<scriptSourceDirectory>脚本源码目录</scriptSourceDirectory>
<testSourceDirectory>单元测试使用的源码目录</testSourceDirectory>
<outputDirectory>序class文件存放的目录</outputDirectory>
<testOutputDirectory>测试class文件存放的目录</testOutputDirectory>
<extensions> 使用来自该项目的一系列构建扩展
<defaultGoal></defaultGoal>当项目没有规定目标默认值
<resources> 描述了项目相关的所有资源路径列表
- <resource>
- - <targetPath></targetPath>
<testResources> 单元测试相关的所有资源路径
<finalName></finalName> 产生的构件的文件名
<filters></filters>使用到的过滤器属性文件列表
<pluginManagement> 子项目可以引用的默认插件信息
<plugins> 该项目使用的插件列表
<dependencies> 项目引入插件所需要的额外依赖
profiles 修改构建处理
<profiles>
<profile>
<id>local</id>
<properties>
<spring.active>local</spring.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<spring.active>test</spring.active>
</properties>
</profile>
</profiles>
modules 子模块
<modules>
<!--子项目相对路径-->
<module></module>
</modules>
repositories 指定仓库
<repository>
<id>current-nexus</id>
<url>http://192.168.10.71:10000/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-aliyun</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
dependencyManagement
继承自该项目的所有子项目的默认依赖信息
distributionManagement 发布信息
配置
<properties>
<name>value</name>
</properties>
Maven添加插件与依赖的区别
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<optional>true</optional>
</dependency>
依赖是项目运行时需要的
插件时项目运行时不需要,打包编译时需要的,比如lombok
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>