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也不会报错,下载速度也比较快
版权声明:本文为momo906原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。