Maven is a Java-based tool, so the first thing to do is to install the JDK.
Maven 3.3 requires JDK 1.7 or above
Maven 3.2 requires JDK 1.6 or above
Maven 3.0/3.1 requires JDK 1.5 or above
The first step is to download the Maven package
Maven download address: http://maven.apache.org/download.cgi
![](https://img-blog.csdnimg.cn/img_convert/1e224190f251b60583d4e3c370aeddf3.png)
![](https://img-blog.csdnimg.cn/img_convert/8af5f9ab8c1997e880bc4bbdf89e4a0e.png)
Download and unzip locally
![](https://img-blog.csdnimg.cn/img_convert/3c47e1ec7af9aa8c57de4fbd069e3aaf.png)
(I downloaded version 3.8.6 here)
The second step configures environment variables
Function: After setting the environment variable, the terminal and IDEA can automatically recognize it
Add the code to the .bash_profile file
Open the terminal (if the environment variable has been configured with .bash_profile), open the configuration file directly, the command is as follows:
open -e .bash_profile
⚠️If you configure environment variables for the first time, you need to create a .bash_profile file in the user's root directory,
#apache-maven-3.8.6环境变量配置
MAVEN_HOME="/Users/wangjiabao/environment/apache-maven-3.8.6"
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME
export PATH
After saving and exiting, execute source on the console to make the configuration file take effect
#source后配置文件才会生效
source .bash_profile
#检查是否source成功 ==> 可以echo出来对应的内容就是设置成功
echo $MAVEN_HOME
Step 3 Alibaba Cloud Mirror Configuration
Purpose (Function): To speed up our download resources (it is recommended to use the mirror image of Alibaba Cloud in China).
Open apache-maven-3.8.6/conf/settings.xml
![](https://img-blog.csdnimg.cn/img_convert/15505fc80c3e745a47f5f08f36c828d5.png)
Add the following code block in the <mirrors></mirrors> tag
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<!--可以配多个镜像-->
![](https://img-blog.csdnimg.cn/img_convert/b4d92fc4b036fa7ddfd0ca3721d520d2.png)
Step 4 local warehouse configuration
Function: Build a local warehouse ( LocalRepository ) so that you don’t have to go to the remote warehouse to download resources every time.
The default local warehouse address is Default: ${user.home}/.m2/repository
We manually create a folder to store resource packs for easy management!
![](https://img-blog.csdnimg.cn/img_convert/cf1afafbca1fe590a50317367f50bf7d.png)
The first step is to create a folder
It is recommended to create a folder maven-repository under /apache-maven-3.8.6/, namely /apache-maven-3.8.6/maven-repository, and copy the path of maven-repository.
![](https://img-blog.csdnimg.cn/img_convert/2defd177bc23852614b47c0c8129263c.png)
The second step, add configuration
在settings文件中<localRepository>标签中添加maven-repository的路径,并填入配置文件中即可。
<localRepository>maven-repository的路径</localRepository>
![](https://img-blog.csdnimg.cn/img_convert/b2128dc23691f7d43b95d1d3e4087501.png)
第五步 配置IDEA的全局MAVAEN
不打开项目,在欢迎页面进入偏好设置
![](https://img-blog.csdnimg.cn/img_convert/a9caf9fd5a88301d9cf88e6f44293a95.png)
![](https://img-blog.csdnimg.cn/img_convert/bb9487245fccb4c4fbc2c75f7ed9151b.png)
这里设置后,以后新建的项目都是默认配置这个版本的maven环境。