maven下载包慢解决
现在maven项目非常流行,因为它对jar实行了一个非常方便的管理,我们可以通过在pom.xml文件中做对应的配置即可将所需要的jar包与自己的项目形成依赖。
但是通常我们会因为下载jar包速度缓慢而苦恼,这十分影响开发效率,以及程序员的心情,在IDE下载jar时,无法对IDE做任何动作,只能大眼对小眼。
下载jar速度慢究其原因就是因为很多资源都是国外的,我们下载一个小文件几乎就跨越了一个太平洋那么远,那么有什么方法可以让下载速度变快呢?
其实方法很简单:maven是支持镜像的,我们可以在maven的conf文件加下的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> -->
</mirrors>
在这个标签中加入国内的镜像即可,在这里推荐阿里云的镜像,下载速度有明显的加快
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
如果.m2目录下没有setting.xml,可以在maven安装目录下的conf下复制一份。
如果搭建了nexus的话,可以指向自己的maven私服
<mirror>
<id>my</id>
<name>My Central</name>
<url>http://私服IP/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
- 13 小时前发布
还没有评论,来说两句吧...