首先确保,你已经创建好了settings.xml文件。
mirrors元素配置代码如下:
<mirrors> <!-- 阿里镜像 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> <!-- 注意:这里使用的是 http,但通常建议使用 https(如果阿里云支持的话)--> </mirror> <!-- Ibiblio 镜像 --> <mirror> <id>ibiblio</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for Ibiblio Mirror</name> <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url> </mirror> <!-- JBoss 公共仓库组镜像 --> <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> </mirror> <!-- Google Maven Central 镜像(已更正 URL) --> <mirror> <id>google-maven-central</id> <name>Google Maven Central</name> <url>https://maven-central.storage.googleapis.com/</url> <mirrorOf>central</mirrorOf> </mirror> <!-- 中央仓库在中国的镜像 --> <mirror> <id>maven.net.cn</id> <name>One of the central mirrors in China</name> <url>http://maven.net.cn/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <!-- 如果需要,可以继续添加其他镜像 --> </mirrors>
<!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|-->
//其中这部分可以不要,注意<!--注释内容-->,上面部分是注释内容
如果有什么问题,评论交流!