mac系統下,在eclipse裡配置maven的國內映象
阿新 • • 發佈:2018-12-10
1. 點選前往檔案夾
輸入/users/<user name>/.m2
回車
進入到該目錄下,建立settings.xml,預設是沒有該檔案的,eclipse的maven工具安裝時不會新建該檔案
而該檔案上方的repository資料夾是用來存放通過maven下載的外掛的,如下圖
2. 開啟eclipse偏好設定
進入maven-user settings,點選user setting的browse按鈕
選擇新建的settings.xml檔案
user setting右邊就會出現open file按鈕
點選open file按鈕就會在eclipse裡面開啟settings.xml檔案
3. 在開啟的檔案裡輸入
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <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>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> <mirror> <id>nexus-aliyun-thirdparty</id> <mirrorOf>thirdparty</mirrorOf> <name>Nexus aliyun thirdparty</name> <url>http://maven.aliyun.com/nexus/content/repositories/thirdparty/</url> </mirror> </mirrors> <profiles> <profile> <id>default</id> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> </settings>
參考:
把參考文章裡的連結換成aliyun的,開源中國的用不了了
用文章裡的寫法不會報無法讀取settings.xml錯誤
而且經過試驗,下載好外掛後,pom.xml也不會報錯,下載速度也比較快