maven 配置多个仓库的方法
1>方法一
之前在配置 Maven 的 settings.xml 时,都会设置 mirror 节点,例如:
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
然后第一想法就是在 mirrors 节点下多增加几个 mirror,然而并不可以。正确的操作是在 profiles 节点下配置多个 profile,而且配置之后要激活。例如:
配置profiles
<profiles>
<profile>
<id>boundlessgeo</id>
<repositories>
<repository>
<id>boundlessgeo</id>
<url>https://repo.boundlessgeo.com/main/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>maven-central</id>
<repositories>
<repository>
<id>maven-central</id>
<url>http://central.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profiles>
通过配置 activeProfiles 子节点激活
<activeProfiles> <activeProfile>boundlessgeo</activeProfile> <activeProfile>aliyun</activeProfile> <activeProfile>maven-central</activeProfile> </activeProfiles>
如果在IDE里,记得要更新生效,然后就可以了。
2> 方法二
在项目中添加多个仓库,是通过修改项目中的pom文件实现的。
思路:在项目中pom文件的repositories节点(如果没有手动添加)下添加多个repository节点,每个repository节点是一个仓库。
<repositories>
<repository>
<!-- id必须唯一 -->
<id>jboss-repository</id>
<name>jboss repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
<repository>
<id>aliyun-repository</id>
<name>aliyun repository</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
<repository>
<id>奇葩仓库</id>
<url>https://奇葩仓库/public/</url>
</repository>
</repositories>
到此这篇关于maven 配置多个仓库的方法的文章就介绍到这了,更多相关maven 多个仓库配置内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
SpringBoot实现Server-Sent Events(SSE)的使用完整指南
使用SpringBoot实现Server-Sent Events(SSE)可以有效处理实时数据推送需求,具有单向通信、轻量级和高实时性等优势,本文详细介绍了在SpringBoot中创建SSE端点的步骤,并通过代码示例展示了客户端如何接收数据,适用于实时通知、数据展示和在线聊天等场景2024-09-09
SpringBoot使用thymeleaf实现一个前端表格方法详解
Thymeleaf是一个现代的服务器端 Java 模板引擎,适用于 Web 和独立环境。Thymeleaf 的主要目标是为您的开发工作流程带来优雅的自然模板,本文就来用它实现一个前端表格,感兴趣的可以了解一下2022-10-10


最新评论