maven 更新jar很慢解决办法--配置阿里云镜像

我们都知道,当我们在pom文件里面添加一个新的依赖时,maven发现本地仓库里面没有该jar包就会到中央仓库去下载,但是中央仓库在国外,下载的速度比蜗牛还慢,

解决方法:配置国内镜像(如阿里云的镜像)

修改conf/settings.xml文件,文件的具体位置可以在这里查看,话说不如图解

 

如果说你是第一次配置的话,可能是Bundled(Maven 3)也可能是别的,点击右面下拉三角形也可以看到,安装maven的路径

修改上面路径下的 conf/settings.xml文件

配置阿里云镜像代码如下

<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>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
  <mirror> 
    <id>uk</id>  
    <mirrorOf>central</mirrorOf>  
    <name>Human Readable Name for this Mirror.</name>  
    <url>http://uk.maven.org/maven2/</url> 
  </mirror>
   <mirror>
    <id>CN</id>
    <name>OSChina Central</name>
    <url>http://maven.oschina.net/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
  <mirror>
    <id>nexus</id>
    <name>internal nexus repository</name>
    <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
    <url>http://repo.maven.apache.org/maven2</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
</mirrors>
配置完更新一下maven所需的jar包

选择项目--》右击--》Maven--》Reimport

这时,你会发现你的更新速度快了一万呗,很快就更新完成了。

注意:你配置了从哪个仓库下载jar包之后,一定要在IDEA或者eclipse中进行配置,因为默认会选择从Bundled(Maven 3)等,从国外下载。

博客参考:https://blog.csdn.net/Huangjie515/article/details/53494457

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章