1、maven/conf/settings.xml配置
仓库配置信息
<profiles>
<!-- 开发环境(snapshots环境) -->
<profile>
<id>dev</id>
<properties>
<repository.id>dev</repository.id>
<repository.name>Dev Repository</repository.name>
<repository.url>http://10.2.2.36:8081/repository/maven-snapshots/</repository.url>
</properties>
</profile>
<!-- 正式环境(releases环境) -->
<profile>
<id>pro</id>
<properties>
<repository.id>production</repository.id>
<repository.name>Production Repository</repository.name>
<repository.url>http://10.2.2.36:8081/repository/maven-releases/</repository.url>
</properties>
</profile>
</profiles>
仓库账号密码信息
<servers>
<server>
<id>dev</id>
<username>admin</username>
<password>123456</password>
</server>
<server>
<id>pro</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
设置默认开发环境
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
2、pom.xml 仓库地址设置
<!--定义snapshots库和releases库的nexus仓库地址-->
<distributionManagement>
<repository>
<id>${repository.id}</id>
<url>${repository.url}</url>
<name>${repository.name}</name>
<layout>default</layout>
</repository>
</distributionManagement>
3、部署上传
# 使用配置的默认环境
maven clean deploy
# 指定生产环境
maven clean deploy -Ppro
【一起学习】