# settings.xml
在servers部分配置用户名和密码
<server>
<id>rdc-releases</id>
<username>w2FOuo</username>
<password>MIuUNMN10q</password>
</server>
<server>
<id>rdc-snapshots</id>
<username>w2FOuo</username>
<password>MIuUNMN10q</password>
</server>
profiles配置私有仓库的地址
<!-- 阿里云个人仓库 -->
<profile>
<id>rdc-private-repo</id>
<repositories>
<repository>
<id>rdc-releases</id>
<url>https://repo.rdc.aliyun.com/repository/119931-release-A1NNN4/</url>
</repository>
<repository>
<id>rdc-snapshots</id>
<url>https://repo.rdc.aliyun.com/repository/119931-snapshot-wPkGqM/</url>
</repository>
</repositories>
</profile>
# pom.xml
<distributionManagement>
<repository>
<id>rdc-releases</id>
<url>https://repo.rdc.aliyun.com/repository/119931-release-A1NNN4/</url>
</repository>
<snapshotRepository>
<id>rdc-snapshots</id>
<url>https://repo.rdc.aliyun.com/repository/119931-snapshot-wPkGqM/</url>
</snapshotRepository>
</distributionManagement>
# 总结
server中配置的用户名和密码是绑定到id上的,故server中的id要与distributionManagement声明的id一致才能被使用.
同理,使用自建的服务器配置如下:
settings.xml 中的 servers 部分
<!-- jun@xinruiyun -->
<server>
<id>jun-xinruiyun-releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>jun-xinruiyun-snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
profile 部分
<!-- jun@新睿云 个人仓库 -->
<profile>
<id>jun-xinruiyun-private-repo</id>
<repositories>
<repository>
<id>jun-xinruiyun-releases</id>
<url>http://113.142.69.171:8850/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>jun-xinruiyun-snapshots</id>
<url>http://113.142.69.171:8850/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
</profile>
项目的顶级 pom 配置
<distributionManagement>
<repository>
<id>jun-xinruiyun-releases</id>
<url>http://113.142.69.171:8850/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>jun-xinruiyun-snapshots</id>
<url>http://113.142.69.171:8850/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
示例 https://gitee.com/fengyexjtu/maven-config/raw/master/settings.xml (opens new window)