在国内使用maven下载jar包非常慢的解决方法

1、原因:

很多jar包在国外环境,所以会很慢。

2、解决方法

maven支持镜像环境下载,所以首先找到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>
     -->
  </mirrors>

将这里的镜像环境改为国内的镜像环境(推荐使用阿里的镜像环境):

<mirrors>
    <mirror>
     <id>alimaven</id>  
     <mirrorOf>central</mirrorOf>  
     <name>aliyun maven</name>  
     <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>  
    </mirror>
  </mirrors>

之后再下载jar包就会快很多了。

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2022-03-04
  • 2021-06-22
  • 2021-05-07
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2021-07-19
  • 2022-12-23
  • 2021-10-16
  • 2021-11-28
  • 2022-12-23
  • 2021-06-01
  • 2021-04-18
相关资源
相似解决方案