Maven为何使用镜像

来源:互联网 发布:淘宝客交易成功后退款 编辑:程序博客网 时间:2024/06/04 01:20

转: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镜像(阿里云镜像)(还有开源中国的镜像也不错,国内镜像还有很多开源上网搜下)

[html] view plain copy
  1. <mirrors>  
  2.   <!-- mirror  
  3.    | Specifies a repository mirror site to use instead of a given repository. The repository that  
  4.    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used  
  5.    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.  
  6.    |  
  7.  -->  
  8.  <mirror>  
  9.     <id>alimaven</id>  
  10.     <name>aliyun maven</name>  
  11.     <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
  12.     <mirrorOf>central</mirrorOf>          
  13.   </mirror>  
  14. </mirrors>  

0 0
原创粉丝点击