一. 下载Maven

1. 官网

2. 下载

3. 安装

二. 配置Maven

  • apache-maven-3.9.9\conf 下的settings.xml 文件进行全局配置。

1. 本地仓库路径

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

默认路径:~/.m2/repository

2. 远程镜像仓库

<settings>
    <mirrors>
        <!-- 其他镜像... -->
        <mirror>
            <id>aliyunmaven</id>
            <mirrorOf>*</mirrorOf>
            <name>阿里云公共仓库</name>
            <url>https://maven.aliyun.com/repository/public</url>
        </mirror>
    </mirrors>
    
    <!-- 可选:配置中央仓库使用镜像 -->
    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>https://maven.aliyun.com/repository/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

mirrorOf 常用值:central(中央仓库),*(所有仓库)

验证
终端执行:mvn help:effective-settings
检查输出中的 <mirrors> 部分是否包含阿里云配置

三. IDEA配置Maven

1. 设置Maven

2. 设置环境

  • -DarchetypeCatalog=internal