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
仓库的镜像,如果仓库配置了镜像,就会去镜像中下载。
元素 | 类型 | 描述 |
---|---|---|
mirrorOf | String | 镜像的仓库id,也就是说是那个仓库的镜像 |
name | String | 镜像的名字 |
url | String | 地址 |
layout | String | layout,默认default |
mirrorOfLayouts | String | 镜像的仓库的layout,默认值为default,legacy |
id | String | id,默认default |
mirrorOf
*
匹配所有的仓库external:*
匹配所有远程仓库,使用localhost的除外,使用file://协议的除外。也就是说,匹配所有不在本机上的远程仓库。- 多个仓库可以使用英文逗号分隔
- 使用感叹号排除指定的仓库
举例:
repo,repo1
匹配repo 或者 repo1
*,!repo1
匹配除了repo1的所有
在匹配的时候,会先找精确匹配的,如果没有用第一个匹配的。