简单介绍setting.xml中 mirrorOf 的配置对构件下载的影响
<settings>
...
<mirrors>
<mirror>
<id>other-mirror</id>
<name>Other Mirror Repository</name>
<url>https://other-mirror.repo.other-company.com/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
</settings>
说明:安装的maven环境都会继承超级POM,可以在$M2_HOME/lib/maven-model-builder-3.3.9.jar 看到,查看具体路径:
maven-model-builder-3.3.9.jar\org\apache\maven\model
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nR1CBus3-1587984109292)(C:\Users\admin\AppData\Roaming\Typora\typora-user-images\1587979377145.png)]
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
的值为central,表示该配置为中央仓库,与上文的repository id一致,如果配置了私服,则可以修改mirrorof的值,这里简单介绍一下mirrorOf中值的配置
- * 匹配所有的远程仓库
- external:* 匹配所有远程仓库,使用localhost的除外,使用file://协议的除外。也就是说,匹配所有不在本机上的远程仓库
- repo1,repo1 匹配仓库repo1和repo2,使用逗号分隔多个远程仓库
- *,!repo3 匹配所有远程仓库,repo3除外,使用感叹号将仓库从匹配中排除
o3 匹配所有远程仓库,repo3除外,使用感叹号将仓库从匹配中排除
注意:id在setting.xml文件中唯一, mirrorOf不能和任何mirror的id一致