一、下载Maven包并解压
资源地址推荐:
Maven官网
IDEA自带Bundled (Maven 3)
二、配置环境变量
1.新增MAVEN_HOME值为maven地址
2.Path变量添加%MAVEN_HOME%\bin
3.mvn -v验证
三、配置settings.xml文件
1.文件地址
D:\apache-maven-3.8.5-bin\conf目录下找到文件
2.配置本地仓库地址
手动配置自己的本地仓库地址,默认为C盘用户目录下,防止之后使用占用C盘过多空间,建议手动配置到其他地址。
3.配置远程镜像仓库
默认为国外的服务器下载jar包,将其添加为多个国内镜像仓库(mirrors标签之间)
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<!-- 中央仓库在中国的镜像 -->
<mirror>
<id>maven.net.cn</id>
<name>oneof the central mirrors in china</name>
<url>http://maven.net.cn/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!--开源中国镜像仓库-->
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public</url>
<mirrorOf>central</mirrorOf>
<!--表示匹配原仓库的请求都转到镜像仓库-->
</mirror>
四、IDEA配置
总结
以上就是自己学习进行Maven环境搭建的内容,不足之处还望各位大佬多多包涵。