mvn package、mvn install、mvn deploy比较
mvn package:打包到target下
mvn install:打包target下,并安装到maven本地仓库
mvn deploy:打包到target下,并安装到maven本地仓库,并部署到maven远程仓库
pom.xml中distributionManagement
配置发布仓库与快照仓库
<distributionManagement>
<repository>
<id>xxx</id>
<url>xxx</url>
</repository>
<snapshotRepository>
<id>xxx</id>
<url>xxx</url>
</snapshotRepository>
</distributionManagement>
需要注意的是:如果远程仓库需要登录,那么需要在maven的配置文件setting.xml中进行配置server,仓库(repository)中的id需要与server中的id保持一致。
<server>
<id>xxx</id>
<username>xxx</username>
<password>xxx</password>
</server>
dependencyManagement、dependencys比较
dependencyManagement:其中的dependency只是声明、定义,不会真的引入依赖
dependencys:其中的dependency会实际引入依赖
dependencyManagement一般用于父pom中,这样多个子pom就可以复用了,并且可以在子pom中指定依赖新的版本号。除了复用,另一个好处是多个子pom复用的情况下,做到了同一个依赖在多个子pom之间的版本号一致,便于管理。