参考博客 https://blog.csdn.net/liangyihuai/article/details/57406870

如何获取maven设置文件的位置?

以使用IDEA开发为例:打开IntelliJ IDEA->Settings ->Build, Execution, Deployment -> Build Tools > Maven

找到User settings file:栏,文本框中即为地址,一般情况下在c:\Users\xx.m2\这个目录下面没有settings.xml文件,可以新建一个settings.xml文件,写入:

设置阿里镜像源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">

<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>

华为镜像源(未尝试)

1
2
3
4
5
6
<mirror>
<id>huaweicloud</id>
<mirrorOf>central</mirrorOf>
<name>huaweicloud</name>
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
</mirror>