一、安装本地Maven
点此进入[maven](https://maven.apache.org/download.cgi)官网下载
选择左侧Download
下载完成后,选择一个路径进行解压
然后配置path环境变量,如图
path:
然后win+R 运行cmd 输入 mvn -version,如图所示则配置成功
二、配置settings文件
1、在F:\dev\apache-maven-3.6.1\conf下可以找到settings文件,打开(嫌麻烦的直接看最后一步)
2、 找到第52行,这里是maven默认的仓库
3、 我们复制第53行
/path/to/local/repo
将它拿到注释外并将中间的内容改成你需要的路径,
F:/repository
这里的路径随便设置,注意这里是正斜杠
4、 因为国外的服务器下载jar包很慢所以我们改为阿里云服务器(大约在150行左右),这两个仓库只用选一个(根据大家反馈建议使用第一个,第二个在有的版本可能会出现warning)
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
或者
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
5、 如图,要夹在两个mirrors标签之间
6、 在最后配置jdk,也要夹在两个profiles标签之间
jdk-1.8 true 1.8 <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>
7、 配置完成,在命令行输入mvn help:system测试,看到下载链接里面是ailiyun的链接表示配置成功
8、 嫌麻烦的直接复制配置文件的内容即可,不过路径还是要改(参考第3步)
<?xml version="1.0" encoding="UTF-8"?>F:/repository
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
<!-- mirror
<mirrors>
| 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.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
</mirrors>
-->
<!-- 阿里云仓库 -->
nexus-aliyun * Nexus aliyun http://maven.aliyun.com/nexus/content/groups/public
jdk-1.8 true 1.8
<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>