一、下载maven
1. maven的下载路径
(1)Apache官网:https://maven.apache.org
(2)https://pan.baidu.com/s/1Yvv44ICGSxGzMnfyXrZO4A 提取码:j27n
二、Apache官网的下载步骤
![](https://img.haomeiwen.com/i11212016/bff9694d00fb1217.png)
![](https://img.haomeiwen.com/i11212016/2074ad848de76b92.png)
![](https://img.haomeiwen.com/i11212016/c962f405a1e9b22a.png)
![](https://img.haomeiwen.com/i11212016/f382b1087c6319f7.png)
![](https://img.haomeiwen.com/i11212016/be50d420664d2e3a.png)
三、安装maven
1. 安装
解压即可
![](https://img.haomeiwen.com/i11212016/c5e8fad5bd8685b0.png)
四、配置maven的环境变量
![](https://img.haomeiwen.com/i11212016/757549ba0571ac33.png)
五、验证maven是否安装成功
![](https://img.haomeiwen.com/i11212016/f05442390b54b954.png)
六、配置maven的本地仓库
1. 新建文件夹maven-repository,用作maven的本地仓库
![](https://img.haomeiwen.com/i11212016/1a7330cf0c9d2420.png)
2. 在maven安装包的conf文件夹中,找到settings.xml文件
![](https://img.haomeiwen.com/i11212016/8f38a2350aa7efcc.png)
3. 打开settings.xml文件,找到 "<localRepository>/path/to/local/repo</localRepository>",取消注释,并将其值改为maven本地仓库的地址
![](https://img.haomeiwen.com/i11212016/389610400afa5036.png)
4. 在 cmd 下执行命令 "mvn help:system",新配置的maven仓库中就会出现很多文件,这些文件就是maven从中央仓库下载到本地仓库的文件
![](https://img.haomeiwen.com/i11212016/6e1989a1802c727b.png)
![](https://img.haomeiwen.com/i11212016/b0e13379117bf76c.png)
![](https://img.haomeiwen.com/i11212016/e322ee9865ff8291.png)
七、配置maven镜像
1. 配置阿里云maven镜像,提高jar包的下载速度
(1)<mirrorOf> 的值为 central,表示该配置为中央仓库的镜像。任何对于中央仓库的请求都会转至该镜像
(2)镜像一般都是和私服结合使用
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
![](https://img.haomeiwen.com/i11212016/34f3f31bb32807f1.png)
2. 配置私服
(1)<mirrorOf> 的值为星号(*),表示该配置是所有maven仓库的镜像。任何对于远程仓库的请求都会被转至私服(eg:http://192.168.1.100/maven2/)
(2)如果该镜像仓库需要认证,则配置一个 id 为 internal-repository 的 <server> 即可
<settings>
...
<mirrors>
<mirror>
<id>internal-repository</id>
<name>Internal Repository Manager</name>
<url>http://192.168.1.100/maven2</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
...
</settings>
<server>
<id>internal-repository</id> <!-- 某个repository元素配置的id -->
<username>repouser</username>
<password>repopwd</password>
</server>
网友评论