时间:2021-05-19
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节点是一个仓库。
到此这篇关于maven 配置多个仓库的方法的文章就介绍到这了,更多相关maven 多个仓库配置内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
maven仓库配置仓库优先级为:本地仓库(localRepositories)>profile中的repositories仓库>POM>mirrors全局仓库通
1.grade配置Error:Couldnotfindcom.android.tools.build:gradle:2.2.1.解决方法与Maven仓库有点像:
今天用androidstudio3.0打开项目时发现一直在谷歌的maven仓库加载卡到这不动了,看了下maven仓库的配置发现:buildscript{repo
在上一篇文章中完成了《Maven镜像地址大全》,后来又花了时间又去收集并整理了关于maven远程仓库地址,并整理于此,关于Maven远程仓库地址的配置方式有两种
大家使用maven下载jar包会很慢,最主要的原因是maven的仓库在英国,但如果使用了阿里的仓库下载jar包就会变得很便捷。下面是如和配置阿里的仓库。alim