maven之Nexus的配置【setting.xml配置镜像<mirror>
来源:互联网 发布:centos 防止arp 编辑:程序博客网 时间:2024/06/05 09:06
前面已经讲解了配置nexus共享仓库。启动了nexus服务后,本地仓库下载jar包都是从nexus里下载,如果nexus里没有,nexus会与maven的中央仓库打交道,然后下载对应的依赖包。当关闭了nexus服务后,本地仓库就会跳过nexus,直接去maven中央仓库下载依赖包了。
如果我们不希望本地仓库直接去maven中央仓库下载,而必须要从nexus里下载依赖包,如果nexus里没有对应的依赖包,就下载不了。
要实现这种效果,需要在setting里配置镜像(<mirror>),让所有的仓库都从这个镜像的url(仓库)中下载依赖。
setting里配置了镜像以后,本地仓库就不再与nexus打交道了,而是直接与镜像中配置的的url(仓库)进行打交道。
这里说明一下,不管是在pom.xml里配置了<repositories>去指向nexus仓库,还是在setting.xml里配置<profile>去指向nexus仓库,当从本地仓库去下载依赖的时候,如果nexus里找不到对应的依赖包,会默认的去maven仓库里下载。即使是nexus服务关闭了,本地仓库还是会去maven中央仓库下载对应依赖包。这是maven里面的默认配置(maven-model-builder-3.3.3.jar里pom-4.0.0.xml文件配置了id为central的中央仓库)。
- <profiles>
- <profile>
- <id>nexusProfile</id>
- <repositories>
- <repository>
- <id>xxx</id>
- <name>111</name>
- <url>http://localhost:8081/nexus/content/groups/public/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- <layout>default</layout>
- </repository>
- </repositories>
- </profile>
- </profiles>
- <activeProfiles>
- <!--激活了才生效-->
- <activeProfile>nexusProfile</activeProfile>
- </activeProfiles>
配置镜像后,下载依赖包的流程为:
如果没有把默认的central仓库配置到镜像里,
- <mirror>
- <id>mirrorId</id>
- <!--表示访问哪些工厂时需要使用镜像-->
- <mirrorOf>xxx</mirrorOf>
- <name>Human Readable Name for this Mirror.</name>
- <url>http://localhost:8081/nexus/content/groups/public/</url>
- </mirror>
流程如下:
(1)配置了镜像后,当要下载依赖时,第一步:找到setting.xml中激活的profile下repository里id为xxx的配置,而xxx已经配置在里镜像里
(2)这时会去到到镜像里的url(仓库)里下载依赖
(3)当发现镜像里配置的url(仓库)里下载不到对应的依赖时,会自动去找到maven中默认的id为central,url为中央仓库地址的repository配置,因为central没有配置在镜像中,所以此时可以直接去到maven中央仓库下载依赖包。
结果如下图所示:
如果已经把默认的central仓库配置到镜像里,
- </pre><pre name="code" class="html"><mirror>
- <id>mirrorId</id>
- <!--表示访问哪些工厂时需要使用镜像-->
- <!--<mirrorOf>xxx,central</mirrorOf> -->
- <mirrorOf>*</mirrorOf> <!--一般用*号-->
- <name>Human Readable Name for this Mirror.</name>
- <url>http://localhost:8081/nexus/content/groups/public/</url>
- </mirror>
流程如下:
(1)配置了镜像后,当要下载依赖时,第一步:找到setting.xml中激活的profile下repository里id为xxx的配置,而xxx已经配置在里镜像里
(2)这个时候会去到到镜像里的url(仓库)里下载依赖
(3)当发现镜像里配置的url(仓库)里下载不到对应的依赖时,会自动去找到maven中默认的id为central,url为中央仓库地址的repository配置,
(4)此时central配置在镜像中,所以这次是去到到镜像里的url(仓库)里下载依赖了。而不会去访问maven中央仓库了。
- maven之Nexus的配置【setting.xml配置镜像<mirror>】(七)
- maven之Nexus的配置【setting.xml配置镜像<mirror>
- 配置maven的mirror(镜像)
- maven之Nexus的配置【setting.xml里配置<profile>】(六)
- Maven自定义镜像Nexus的setting配置(.m2目录下面)
- 【maven】setting.xml配置国内镜像地址
- maven的setting.xml配置
- Nexus私服setting.xml配置
- maven中setting.xml的阿里云aliyun镜像配置
- maven setting为什么需要配置镜像
- 【maven】在setting文件配置中央仓库的镜像
- maven配置---setting.xml的配置
- maven setting.xml配置
- maven setting.xml 配置
- maven setting.xml配置
- Maven之setting.xml配置详解
- maven基础之setting.xml常用配置
- nexus maven setting 和pom 文件配置
- strtok、strtok_s、strtok_r 字符串分割函数
- oracle添加dblink
- [LeetCode] First Bad Version
- 姿态论文整理--02-Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
- 关于两个数字顺序颠倒函数的几种常见错误
- maven之Nexus的配置【setting.xml配置镜像<mirror>
- Unity中摄像机自适应
- JSON数据格式
- MySql 之EXPLAIN 关键字
- 线程安全非线程安全的区别
- MySQL中 Too many connections错误的解决办法
- python分析谷歌浏览器的历史记录
- Zookeeper集群为什么要是单数
- thymeleaf学习笔记