type
status
date
slug
summary
tags
category
icon
password
安装配置
命令
complie命令支持java@5/java@8
运行jar包
依赖配置
- groupId/artifactId/version基本坐标
- type依赖类型,packaging,default类型为jar
- compile,编译范围,编译,运行,测试
- test,测试范围
- provided,提供的依赖范围
- runtime,运行时依赖范围
- system,系统依赖范围
- import,导入范围,compile/test/provided/runtime/system
依赖传递
my-project —> spring framework —> common-logging
默认依赖范围是compile,依赖传递性
当范围女为test则不会传递
当范围为provided时,传递范围也为provided
compile → compile
provided → provided
compile → runtime
可选依赖
<optional>
在实际依赖项中显式声明
依赖排除
<exclusions>
依赖归类
<properties> 同类version
仓库分类
- 本地仓库
settings配置本地仓库 — ~/.m2/settings.xml
user/xxx/.m2/repo
- 中央仓库
<repositories> <repository>
用户认证
<servers> <server> <id> repository id username / password
- 部署配置 mvn deploy
<distributionManagement> <repository> release / snapshots
快照开发途径 xx-SNAPSHOT mvn clean install -U
镜像
X仓库中获取Y仓库中的所有内容,X为Y的镜像
<mirrors> <mirror> <mirrorOf>镜像仓库名称
生命周期
编译 — 测试 — 打包 — 部署
- 插件绑定
生命周期和插件相互绑定
- clean
- pre-clean
- clean
- post-clean [maven-clean-plugin:clean]
2.site
- pre-site
- site
- post-site
- deploy-site [maven-site-plugin:site/deploy]
3.process-resources [maven-resources-plugin:resources]
4.compile [maven-compile-plugin:compile]
5.process-test-resources
6.test-compile
7.test [maven-surefire-plugin:test]
8.package [maven-jar-plugin:jar]
9.install [maven-install-plugin:install]
10.deploy [maven-deploy-plugin:deploy]
- 自定义绑定插件
项目源码jar包 — mvn verify
maven-surefire-plugin
mvn install -Dmaven.test.skip=true
maven-compile-plugin
1.8
mvn help:describe-Dplugin=org.apache.maven.plugins:maven-compile-plugin:2.1
mvn help:describe-Dplugin=comilper
mvn help:describe-Dplugin=comilper-Dgoal=comilpe
mvn help:describe-Dplugin=comilper-Dgoal=comilpe-Ddetail
聚合
<modules> <module>
继承
<relativePath> 指定父pom的相对位置
依赖管理
<dependencyManagement>
聚合与继承
约定大于配置
默认约定
src/main/java/
<build> <sourceDirectory>
target/classes/
jar
target/
web集成
<packaging> war
私服
nexus
持续集成
jenkins
编写插件
mvn archetype:generate
maven-archetype-plugin
mvn clean install
在另一个项目中引用