使用阿里云maven镜像

综述

默认maven仓库在国内访问实在是太慢了,经常下载失败,试过几个镜像后,发现阿里云的maven镜像速度不错。

修改方法

一般不建议直接改maven的全局配置文件,所以我们到`/path/to/maven/conf/`下面复制一份settings.xml到用户目录的.m2目录下,即`~/.m2/`,然后编辑settings.xml,找到mirros标签,替换为下面的代码即可

<mirrors>
  <!-- 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.
   |
  <mirror>
    <id>mirrorId</id>
    <mirrorOf>repositoryId</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://my.repository.com/repo/path</url>
  </mirror>
   -->
 <mirror>
   <id>nexus-aliyun</id>
   <mirrorOf>*</mirrorOf>
   <name>Nexus aliyun</name>
   <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
 </mirror>
</mirrors>