转:http://blog.csdn.net/zhouzhiwengang/article/details/57664942
为什么需要配置maven国内镜像?
1、
在不配置镜像的情况下,maven默认会使用中央库.
2、maven中央库在国外,有时候访问会很慢,尤其是下载较大的依赖的时候,有时候速度会很慢,甚至会出现无法下载的情况.
3、为了解决依赖下载速度的问题,需要配置maven国内镜像
镜像配置方式和比较
1、
maven镜像有两种配置,一种是在settings.xml中进行配置,第二种是在pom.xml中进行配置.
2、在settings.xml中进行配置会对所有maven工程有效,当在升级maven版本的时候,需要注意复制已经配置好的settings.xml到新的maven目录下
3、使用第一种配置pom.xml的方式只会对当前工程有效,本文建议大家使用第二种配置方式。.
配置国内maven镜像(阿里云镜像)(还有开源中国的镜像也不错,国内镜像还有很多开源上网搜下)
- <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>alimaven</id>
- <name>aliyun maven</name>
- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
- <mirrorOf>central</mirrorOf>
- </mirror>
- </mirrors>