如何將預設的maven倉庫改為阿里的maven倉庫
阿新 • • 發佈:2020-12-04
在eclipse中預設的maven,它載入的是國外的映象,那樣速度會比較慢,如果使用國內映象,比如阿里的中央倉庫;速度會快很多。
那如何修改maven倉庫呢?(網上有很多如何修改maven倉庫的方法,這邊我是以我操作的方法,和參考網上的修改方法)
Step-1:去官網https://maven.apache.org/download.cgi下載一個apache-maven工具
Step-2:下載完成之後,在apache-maven-3.5.0/conf資料夾下新建一個settings.xml,並在apache-maven-3.5.0資料夾下建立一個repos資料夾,用於下面在eclipse中將其設定為倉庫的路徑
而settings.xml的內容可以在網上找一個,settings.xml如下
?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>E:\apache-maven-3\apache-maven-3.5.0\repos</localRepository> <pluginGroups> </pluginGroups> <proxies> </proxies> <servers> </servers> <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> --> <mirror> <id>alimaven</id> <mirrorOf>*</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> </mirrors> <profiles> </profiles> </settings>
其中核心的部分為:
<mirror> <id>alimaven</id> <mirrorOf>*</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror>
Step-3:對eclipse進行修改
在window—》preferences
完成之後:切換到maven的視窗
然後重新建立索引
這個過程有點長:
完成後,新建一個maven專案(我這邊已經建好了),開啟pom.xml檔案,進行查詢依賴jar包
這樣說明就OK了
到此這篇關於如何將預設的maven倉庫改為阿里的maven倉庫的文章就介紹到這了,更多相關maven倉庫改為阿里的maven倉庫內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!