1.下载:下载完成后,解压即可
2 配置环境变量
在我们的系统环境变量中:
M2_HOME maven目录下的bin目录
MAVEN_HOME maven的目录
在系统的path中配置 %MAVEN_HOME%\bin
测试Maven是否安装成功
3.Maven配置阿里源
(1)创建Maven本地仓库
创建自定义本地仓库:pom.xml中下载的jar包资源存放与调用的目录路径。
我的仓库路径(非中文目录):D:\Enviroment\apache-maven-3.8.5\maven-repo
(2)打开Maven安装路径,设置conf目录下的settings.xml文件用IDEA中打开。
开始设置
第一:先把本地仓库路径添加到如下位置,参考左边代码的行数
第二:把下面全部代码块,复制放大settings的<mirrors>放到这里面</mirrors>
<!--配置阿里云-->
<mirror>
<id>nexus-aliyun</id>
<name>nexus-aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>alimaven-central</id>
<name>aliyun maven central</name>
<url>https://maven.aliyun.com/repository/central</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>alimaven-spring</id>
<name>aliyun maven-spring</name>
<url>https://maven.aliyun.com/repository/spring</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>https://repo1.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</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>spring-snapshots</id>
<mirrorOf>central</mirrorOf>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
</mirror>
<mirror>
<id>spring-milestones</id>
<mirrorOf>central</mirrorOf>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</mirror>
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
开始结束位置:
第三:测试阿里云配置:在命令行输入mvn help:system测试,看到下载链接里面是ailiyun的链接表示配置成功
4.IDEA配置Maven
配置成功!
遇到报错原因:
1.镜像配置要找与maven相匹配的代码加入
2.maven-repo文件里面要是空的才可以正常下载。