原文:IntelliJ IDEA设置Maven国内阿里镜像_idea国内镜像_counsellor的博客-CSDN博客

0x00 前言

最近用IntelliJ IDEA构建Maven项目,但是reimport的速度超级慢,应该是官方源在国外的原因,所以改成阿里云的源。

0x01 设置方法

  1. 右键项目,选择Maven->Create ‘settings.xml’(已经存在的话是Open ‘settings.xml’)
    reimport 慢 IntelliJ IDEA设置Maven国内阿里镜像_idea国内镜像_counsellor的博客-CSDN博客 - 图1
  2. 在settings.xml文件中增加阿里云镜像地址,代码如下:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  5. <mirrors>
  6. <mirror>
  7. <id>alimaven</id>
  8. <mirrorOf>central</mirrorOf>
  9. <name>aliyun maven</name>
  10. <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
  11. </mirror>
  12. </mirrors>
  13. </settings>

0x02 使用maven导入依赖库

在pom.xml文件上右击,选择Maven->Reimport
reimport 慢 IntelliJ IDEA设置Maven国内阿里镜像_idea国内镜像_counsellor的博客-CSDN博客 - 图2

0x03 tips

  1. maven 的的全局配置默认路径是C:\Users[当前用户].m2\settings.xml
  2. maven的配置路径可以在settings中的maven中修改