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

2026-10-09 · 项目部署流程

1、Maven下载

官网:https://maven.apache.org/

下载:https://maven.apache.org/download.cgi

2、阿里云镜像加速

进入 Maven 解压目录的 conf 文件夹:

cp settings.xml settings.xml.bak
vi settings.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>${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-21</id>  
      <activation> 
        <activeByDefault>true</activeByDefault>  
        <jdk>21</jdk> 
      </activation>  
      <properties> 
        <maven.compiler.source>21</maven.compiler.source>  
        <maven.compiler.target>21</maven.compiler.target>  
        <maven.compiler.compilerVersion>21</maven.compiler.compilerVersion> 
      </properties> 
    </profile> 
  </profiles> 
</settings>

3、Maven配置环境变量

和 JDK 类似:配置 MAVEN_HOME,再把 %MAVEN_HOME%\bin 加进 PATH。

mvn -v

相关文章

← 返回教程列表

评论正在加载……若这句话一直不消失,说明评论服务暂时连不上,过会儿刷新即可。