一、下载安装配置Maven环境
1、前往https://maven.apache.org/download.cgi下载最新版的Maven程序解压位置按个人习惯、尽量不要太难找不要有空格
2、Maven环境变量配置
新建环境变量MAVEN_HOME 赋值刚才解压的根目录
编辑环境变量Path,追加%MAVEN_HOME%\bin;
3、至此Maven已经完成了安装,可以通过DOS命令检查一下我们是否安装成功输入:mvn -v输出以下内容即可
C:\Users\MrYu>mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.8.0_191
Java home: D:\Program Files\2019 JavaSE\JDK1.8.0_191\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10" version: "10.0" arch: "amd64" Family: "dos"
二、配置本地仓库
1、进入Maven_Home新建一个Repository的文件夹用作maven的本地库、打开maven\conf\settings.xml文件加localRepository配置
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>D:/Program Files/2020_Maven/repo</localRepository>
2、DOS命令输入:mvn help:system在MavenRepository文件夹中会出现新文件
3、接着添加Maven的依赖下载镜像,修改%MAVEN_HOME%\conf\settings.xml文件配置
<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.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
三、IDEA修改Maven插件配置
打开IDEA,在File->OtherSettings->DefaultSettings->Build, Execute, Deployment->Build Tools->Maven
修改 Maven home directory: %MAVEN_HOME%
修改 User settings file: %MAVEN_HOME%\conf\settings.xml (如果不能选择,需要选择override对勾)