功能:
构建项目(Builds)
依赖管理(Dependencies)
Maven特点:
命令行构建maven项目:
mvn archetype:generate
项目基本信息
构建环境
POM关系
构建设置
坐标:
groupId
artifactiId
packaging
version
调用插件目标的两种方式:
将插件目标与生命周期绑定
直接执行
maven常用插件:
maven-archetype-plugins
maven-dependency-plugin
maven-help-plguin
maven-resources-plugin
maven-surefire-plugin
jetty-maven-plugin
maven-enforcer-plugin
maven中项目的生命周期是指项目的构建过程,它包含了一系列的有序的阶段,而一个阶段就是构建过程中的一个步骤。
资源文件处理——编译——类文件处理——测试资源类处理——测试——打包(并不完整)
插件目标可以绑定到生命周期阶段上。一个生命周期阶段可以绑定多个插件目标
maven通过坐标管理依赖。
传递性依赖。
complile
provided
runtime
test
system
mvn clean package
多模块项目:
在Maven中,通常会将一个大型的项目切分成若干个子项目,这些子项目被称为module,也就说模块。
maven构建多模块项目:
modelVersion标签说明当前的pom文件遵循的是哪一个pom版本。必不可少
packaging :打包类型
ear
jar
war
pom 表示当前项目是一个父项目
dependencyManagement的作用:
多个子项目若依赖同一个版本,只在父版本声明dependencyManagement的版本号,子项目中无虚再声明版本号。
父版本用dependencyManagement只是声明依赖,而不会实际的引入依赖。需要在子模块中显示声明依赖。
<dependencyManagement>
<dependencies>
<dependency>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<scope></scope>
</dependency>
</dependencies>
</dependencyManagement>
pluginManagement的作用:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<configuration>
<source></source>
<target></target>
<encoding></encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
定义常量
</properties>