1.下载文件
下载地址:http://maven.apache.org/download.cgi,zip
2.解压压缩包 apache-maven-3.6.3-bin.zip
3.配置环境变量
将M2_HOME追加到path环境变量中
4.cmd ---> mvn -version 出现以下,表示安装成功
5.在cmd下 执行 mvn help:system 命令,下载配置到本地仓库(.m2 / settings.xml)
详见:http://maven.apache.org/settings.html
settings.xml文件可能存在两个位置:
- Maven安装:$ {maven.home} /conf/settings.xml
- 用户的安装:$ {user.home} /.m2 / settings.xml
前一个settings.xml也称为全局设置,后一个settings.xml称为用户设置。如果两个文件都存在,则它们的内容将合并,其中用户特定的settings.xml是主要文件。
提示:如果需要从头开始创建用户特定的设置,则最简单的方法是将全局设置从Maven安装复制到$ {user.home} /。m2目录。Maven的默认settings.xml是带有注释和示例的模板,因此您可以快速对其进行调整以满足您的需求。
也可自定义本地仓库路径,修改settings.xml文件中localRepository标签
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<localRepository>E:\repository</localRepository> 即可。
6.添加中央仓库
<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.
|-->
<!-- aliyun -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>