简介:我们用maven的时候,maven自带的远程中央仓库经常会很慢,还有默认本地仓库是在c盘C:\Users\你的电脑用户账号\.m2\repository,

对于有强迫症的人,总是看的不爽,下面介绍下经验:

 

我的环境:

maven:3.3.9

jdk:1.8_112

intellij idea:2016.3

windows:win10

试验项目:spring boot 1.5.1

 

首先你需要安装maven,我的maven安装的是3.3.9

maven修改远程中央仓库地址:

找到你的maven安装位置,找到conf下的setting.xml,我的位置D:\maven\apache-maven-3.3.9\conf\setting.xml,打开它,

我这里用的sublime3,默认很多都注释了,加入代码:

<profiles>
<profile>
<id>dev</id>
<!-- repositories and pluginRepositories here-->
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>

在这里我们用的是阿里的maven远程中央仓库,试验过网速杠杠的,这个时候可以去实验下你的maven下载,看是不是阿里的远程仓库地址

maven修改本地仓库地址:

还是在这个setting.xml文件,搜索localRepository:

在下面加入一行<localRepository>D:\down\maven-repository\repository</localRepository>,这里是我自己的maven本地仓库地址,改成自己设置的maven本地仓库地址

然后将setting.xml(maven安装的位置D:\maven\apache-maven-3.3.9\conf\setting.xml),复制一份到你设置的maven本地仓库地址下,

这里的地址是D:\down\maven-repository\repository,配置完成了打开intellij idea,打开file->setting,搜索maven:

将这三处修改,第一处是使用自己安装的maven,这个地方有maven2,maven3,maven3.3.9(自己安装的),选择maven3.3.9

第二处是使用自己配置的放在本地仓库的setting.xml文件

第三处是本地仓库的地址,点击apply,ok

然后可以移动下自己pom.xml中的内容,右下角有下载信息,会显示从http://maven.aliyun.com/nexus/content/groups/public下载到自己定义的仓库地址

 

 开源中国地址:https://git.oschina.net/wustxiabin/spring-cloud.git

 github地址:    https://github.com/waterlufei/spring-cloud.git

微信公众号:

 

posted on 2017-03-03 21:33  请叫我小路飞  阅读(48494)  评论(2编辑  收藏  举报