在Maven的settings.xml文件中配置多个仓库,其中基础依赖使用阿里云仓库,其他依赖使用Nexus仓库,可以按照以下步骤进行操作:
第一种方式:
[root@localhost ~]# vim /usr/local/maven/conf/settings.xml
1、在<mirrors>标签中添加如下配置
<mirrors>
<mirror>
<id>aliyun</id>
<name>Aliyun Mirror</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
2、在<profiles>标签内,创建一个新的profile,并添加如下配置
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>https://your-nexus-repo-url</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
注意:把https://your-nexus-repo-url替换为实际的Nexus仓库URL。
3、在<activeProfiles>标签内添加nexus配置, 如下所示
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
第二种方式:
[root@localhost ~]# vim /usr/local/maven/conf/settings.xml
<profiles>
<!-- 公司的私有仓库 -->
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>https://your-nexus-repo-url</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<!-- 阿里云Maven仓库 -->
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>aliyun</id>
<name>Aliyun Repository</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!-- 激活仓库 -->
<activeProfiles>
<activeProfile>nexus</activeProfile>
<activeProfile>aliyun</activeProfile>
</activeProfiles>
注意:把https://your-nexus-repo-url替换为实际的Nexus仓库URL。
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
继续阅读
微信号
微信扫一扫,加我!

微信号已复制
微信公众号
微信扫一扫,关注我!

公众号已复制
评论