maven 仓库优先级

本地仓库 > 私服(profile)> 远程仓库(repository)

比较优先级,只比较这三个,镜像不参与比较。确定优先级后,在看是否有匹配的镜像,有匹配则从镜像下载,无匹配则直接走相关仓库。 多个相同仓库镜像,按照从上到下顺序,依次查找。找到立即停止,后面镜像就不起作用了

maven仓库的执行顺序:
settings_mirror 的优先级高于 central
settings_profile_repo 优先级高于 settings_mirror
settings_profile_repo 优先级高于 pom_repositories
settings_profile_repo 优先级高于 pom_profile_repo
pom_profile_repo 优先级高于 pom_repositories
pom_repositories 优先级高于 settings_mirror
通过上面的比较得出完整的搜索链:

local_repo > settings_profile_repo > pom_profile_repo > pom_repositories > settings_mirror > central

注 :

0、多个mirror会按照顺序执行;第一个没有jar包或者mirrorOf没拦住,才会执行第二个;

1、在mirrorOf与repositoryId相同的时候优先是使用mirror的地址

2、mirrorOf等于*的时候覆盖所有repository配置

3、存在多个mirror配置的时候mirrorOf等于*放到最后,如果多个*,那就按照顺序执行;

4、只配置mirrorOf为central的时候可以不用配置repository

 

多个私服,根据定义从上到下起作用,跟激活配置顺序无关。有很多 spring 包,在阿里云仓库可能有元数据,但是就是下载不了,需要调整相关仓库顺序

 

posted on 2022-05-12 11:54  一直小飞猫  阅读(2924)  评论(0编辑  收藏  举报

导航