生命周期
Maven对项目构建的生命周期划分为3套
clean: 清理工作
default: 核心工作,编译,测试,打包,部署等
site: 产生报告,发布站点等
每个生命周期包含了多个阶段。
这些阶段在执行的时候是有固定顺序的。后面的阶段一定要等前面的阶段执行完成后才能被执行。
# clean生命周期
pre-clean: 执行一些需要在clean之前完成的工作
clean: 移除所有上一次构建生成的文件
post-clean: 执行一些需要在clean之后完成的工作
# default生命周期
太长了,需要的时候百度吧
# site生命周期
pre-site execute processes needed prior to the actual project site generation
site generate the project's site documentation
post-site execute processes needed to finalize the site generation, and to prepare for site deployment
site-deploy deploy the generated site documentation to the specified web server
引用另一个依赖时
<dependency>
<groupId>cn.itcast.demo</groupId>
<artifactId>feign-api</artifactId>
<version>1.0</version>
</dependency>
feign-api
jar包中的类可以被使用,它的pom依赖也会被继承使用
模块的聚合
# 创建一个新的模块,用于构建管理, 该模块中只有pom文件
# 操作这一个模块(compile,clean,install), 其他模块都跟着联动(compile,clean,install)
# 不写packaging的模块默认打包方式是jar包
<packaging>pom</packaging>
# 管理的模块列表
<modules>
<module>module1</module>
<module>module2</module>
</modules>
模块的继承
父模块的pom文件
# 注意打包方式为 pom
# The packaging type required to be pom for parent and aggregation (multi-module) projects.
<packaging>pom</packaging>
# dependencies标签下的依赖会被子工程继承使用
<dependencies>
</dependencies>
# dependencyManagement标签统一控制依赖模块的版本信息
# 子工程只会继承到版本信息
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
# 父模块中的groupId,version,dependencies,properties,dependencyManagement都会被子模块继承
子模块的pom文件
# 继承关系在子工程中描述,使用parent标签
# parent标签只继承parent模块的pom依赖,但不能使用parent模块中编写的类
<parent>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
# 填写父工程的pom文件路径
<relativePath></relativePath>
</parent>
# 子工程的依赖模块可以不再写版本,如果在父工程的dependencyManagement中进行了版本控制的话
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>