IntelliJ 使用自己的 Maven,所以即使我们改了 Windows 的 Maven 配置去使用中国镜像,IntelliJ 也不会使用。
我们需要改变下面文件夹的 settings.xml 文件,我们配置的中国镜像才能生效。
C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.2\plugins\maven\lib\maven3\conf
注意把文件路径中的版本号应该是我们所用的 IntelliJ 对应的版本号。
下面是我们使用阿里镜像的样子。
<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>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>