1、Maven的中央仓库地址默认是:https://repo.maven.apache.org/maven2/,可以通过修改settings.xml文件来修改默认的中央仓库地址:
<profile>
<id>repository-profile</id>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<layout>default</layout>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
要注意的是如果修改的是中央仓库地址,那么repository下面的id标签值一定得是central,此外,还需要激活这个profile才能生效,这里的标签值就是profile标签下面的id标签值
<activeProfiles>
<activeProfile>repository-profile</activeProfile>
</activeProfiles>
2、Maven的镜像是指如果仓库X可以提供仓库Y存储的所有内容,那么就可以认为X是Y的一个镜像,也就是说任何一个可以从仓库Y获得的依赖,都能够从它的镜像中获取。比如阿里的Maven仓库http://maven.aliyun.com/nexus/content/groups/public就可以理解为是中央仓库https://repo.maven.apache.org/maven2/在中国的镜像,由于地理位置的因素,该镜像往往能够提供比中央仓库更快的服务。要为一个仓库配置镜像只需要修改settings.xml文件,如下,其中的mirrorOf标签值就是仓库的id标签值,中央仓库就是默认就是central,表示这是为中央仓库配置的镜像,以后所有的依赖下载都会从这个镜像中进行下载。
<mirror>
<id>central-repository-mirror</id>
<name>Central Repository Mirror</name>
<mirrorOf>central</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>