简单介绍setting.xml中 mirrorOf 的配置对构件下载的影响

说明:安装的maven环境都会继承超级POM,可以在$M2_HOME/lib/maven-model-builder-3.3.9.jar 看到默认继承了中央仓库:

<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

jar包路径:maven-model-builder-3.3.9.jar\org\apache\maven\model

mavensettings文件配置(Mavensetting.xml中镜像配置)(1)

一般的conf/setting.xml中的镜像配置为:

<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>

其中<mirrorOf>的值为central,表示该配置为中央仓库,与上文的repository id一致,如果配置了私服,则可以修改mirrorof的值,这里简单介绍一下mirrorOf中值的配置

注意:id在setting.xml文件中唯一, mirrorOf不能和任何mirror的id一致

,