maven配置国内镜像(阿里云)
2021-05-18 16:24:38
找到`.m2`目录,Windows系统,如下图所示:
![WechatIMG53.png](https://static.daimaku.net/post/202105/18/4b19baccd9ce1152fdbb121ba4c18c62.png)
如果是macOS系统,使用命令 `open ~/.m2`就能进入`.m2`目录。
将下面的内容,保存为`settings.xml`文件,放入 `.m2`目录中
```
<?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">
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers></servers>
<mirrors>
<!-- 阿里云仓库 -->
<!-- 如果无法访问,去这里查看是否换了url https://developer.aliyun.com/mvn/guide -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/central/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>
<profiles></profiles>
</settings>
```