Skip to content

03、Maven下载与阿里云镜像加速

1、Maven下载

2、阿里云镜像加速

Maven settings.xml 配置

xml
<?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">

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>${user.home}/.m2</localRepository>
  <!-- 用户目录下的.m2是所有jar包的地方; maven容器内jar包的位置 -->
  <!--<localRepository>/var/jenkins_home/appconfig/maven/.m2</localRepository>-->

  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
  </servers>

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

  <profiles>
    <profile>
      <id>jdk-1.8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>
  </profiles>

</settings>

3、Maven配置环境变量

和JDK类似

环境变量配置

  • 配置 MAVEN_HOME
  • 配置PATH: %MAVEN_HOME%\bin

验证配置

bash
mvn -v

4、IDEA配置Maven的settings文件

  • 路径: File - Settings - Build, Execution, Deployment - Build Tools - Maven - User settings file:
  • 配置: C:\Users\用户名\.m2\settings.xml