構建maven項目時會下載很多依賴,會從官網地址下載是個外國網站,訪問速度會很慢,但可以通過修改maven的settings.xml文件換成國內的鏡像地址就可以加快訪問速度:
一、找到settings.xml
(1)我的放在C:\Users\zrk\.m2下
(2)idea里依次點File->Settings,在彈出框搜索maven,可以查看或配置路徑
(3)eclipse下可以參考:
https://www.cnblogs.com/flying607/p/6223148.html
二、修改配置
打開settings.xml,搜索mirrors,找到下段代碼
<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. | --> </mirrors>
在mirrors中添加一個<mirror>,保存即可
<mirror> <id>mirrorId</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror>
最終效果: