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>
參考:
https://yq.aliyun.com/articles/6861
把參考文章裏的鏈接換成aliyun的,開源中國的用不了了
用文章裏的寫法不會報無法讀取settings.xml錯誤
而且經過試驗,下載好插件後,pom.xml也不會報錯,下載速度也比較快