maven仓库导包慢的解决办法

故障原因

原因:默认安装的maven使用官网地址下载依赖包,在国内访问比较慢。
方法:将maven配置文件中下载依赖包地址修改成国内地址,一般都使用阿里的地址。

解决方法

1,右键项目名,选择maven
在这里插入图片描述
替换setting.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>repo2</id>       -->
      <!-- <mirrorOf>central</mirrorOf>       -->
      <!-- <name>Human Readable Name for this Mirror.</name>       -->
      <!-- <url>http://repo2.maven.org/maven2/</url>       -->
    <!-- </mirror>    -->

    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf> 
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>
    <mirror>
      <!--This is used to direct the public snapshots repo in the 
          profile below over to a different nexus group -->
      <id>nexus-public-snapshots</id>
      <mirrorOf>public-snapshots</mirrorOf> 
      <url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url>
    </mirror>

  </mirrors>

2.打开本地maven位置,选择setting.xml文件,修改同上位置
在这里插入图片描述
打开.xml文件后替换红框部分:
在这里插入图片描述
重启idea后更新maven仓库,下载飞快。


END

猜你喜欢

转载自blog.csdn.net/cjw12581/article/details/107400572