maven设置多个镜像源,按顺序下载依赖
2022/8/24 23:27:03
本文主要是介绍maven设置多个镜像源,按顺序下载依赖,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
目标
分别配置两个nexus镜像源,目的: 编译时,先从nexus1尝试下载依赖,如果失败,到nexus2下载依赖,再失败,去公网中央仓库下载镜像
配置
settings.xml
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <mirror> <id>nexus1</id> <mirrorOf>nexus1</mirrorOf> <url>http://nexus1.com/nexus/repository/maven-delivery/</url> </mirror> <mirror> <id>nexus2</id> <mirrorOf>nexus2</mirrorOf> <url>http://nexus2.com/repository/maven-public/</url> </mirror> </mirrors> <!-- 配置连接密钥,如果需要认证 --> <servers> <server> <id>nexus1</id> <username>demo</username> <password>demo001</password> </server> </servers> <!-- The resolution of multiple Repositories only works with profiles!--> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>nexus1</id> <url>http://nexus1.com/nexus/repository/maven-delivery/</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> <repository> <id>nexus2</id> <url>http://nexus2.com/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus1</id> <url>http://nexus1.com/nexus/repository/maven-delivery/</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> <pluginRepository> <id>nexus2</id> <url>http://nexus2.com/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles> </settings>
测试
使用mvn插件下载一个不存在的依赖,查看效果
mvn dependency:get -DgroupId=com.github.ggdefe -DartifactId=ggdefe -Dversion=1.0.0
输出
这篇关于maven设置多个镜像源,按顺序下载依赖的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?
- 2024-05-09企业src漏洞挖掘-有意思的命令执行
- 2024-05-08阿里云域名注册流程,分享给第一次购买域名的新手站长!
- 2024-05-082024年,行业变动下的程序员应该首先学习哪种编程语言?