maven下载jar包速度慢 失败的解决方案

现在maven项目非常流行,因为maven十分方便的对所需jar包进行管理,可以通过pom.xml快速引用jar包。

但是通常我们会因为下载jar包速度缓慢而苦恼,这十分影响开发效率,以及程序员的心情,在IDE下载jar时,无法对IDE做任何动作,只能大眼对小眼。

下载jar速度超慢 甚至失败的原因是 许多资源都是国外的,连接外网总是会比较慢的

解决方案很简单:maven是支持镜像的,使用阿里云maven国内镜像,使得下载jar包速度飞起。

在maven的conf文件下的setting文件中  如:E:\Work\SoftWare\apache-maven-3.3.9\conf-->setting.xml   

找到<mirrors></mirrors>标签    加入阿里云仓库代码

<!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
	<!-- 阿里云仓库 -->
	<mirrors>
         <mirror>
            <id>alimaven</id>
            <mirrorOf>central</mirrorOf>
             <name>aliyun maven</name>
             <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
         </mirror>
 
 
         <!-- 中央仓库 -->
         <mirror>
             <id>repo</id>
             <mirrorOf>central</mirrorOf>
             <name>Human Readable Name for this Mirror.</name>
             <url>http://repo1.maven.org/maven2/</url>
         </mirror>
	</mirrors>

猜你喜欢

转载自blog.csdn.net/zhq505824802/article/details/82151489