浅谈Maven 项目中依赖的搜索顺序

http://www.manongjc.com/article/13422.html

 

结论:

只要 ~/.m2/repository 中包含依赖,无论怎么配置,都会优先使用local本地仓库中的jar.

最终结论

  • 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

 

 

mirrors

仓库的镜像,如果仓库配置了镜像,就会去镜像中下载。

元素类型描述
mirrorOfString镜像的仓库id,也就是说是那个仓库的镜像
nameString镜像的名字
urlString地址
layoutStringlayout,默认default
mirrorOfLayoutsString镜像的仓库的layout,默认值为default,legacy
idStringid,默认default

mirrorOf

  • *匹配所有的仓库
  • external:*匹配所有远程仓库,使用localhost的除外,使用file://协议的除外。也就是说,匹配所有不在本机上的远程仓库。
  • 多个仓库可以使用英文逗号分隔
  • 使用感叹号排除指定的仓库

举例:

repo,repo1匹配repo 或者 repo1

*,!repo1匹配除了repo1的所有

在匹配的时候,会先找精确匹配的,如果没有用第一个匹配的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值