maven修改遠程和本地倉庫地址


簡介:我們用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

微信公眾號:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM