1.从官网下载MAVEN 地址:https://maven.apache.org/download.cgi
2.有四种文件格式:下载的是apache-maven-3.3.9-bin.zip
3.解压缩apache-maven-3.3.9-bin.zip
4.用vim打开终端配置环境变量
vim ~/.bash_profile
5.在其中插入两条语句
export M2_HOME=/Users/qiandan/Documents/MAVEN/apache-maven-3.3-2.9
注:maven所在路径 不确定完整路径,可以用pwd命令获取
export PATH=$PATH:$M2_HOME/bin
6:生效环境变量
source ~/.bash_profile
7.测试环境变量是否生效
mav -v
出现以下文字则代表安装配置完成
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /Users/qiandan/Documents/MAVEN/apache-maven-3.3-2.9
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
8.如果失败也可以看下 环境变量是否生效
echo $M2_HOME :查看maven的环境变量
echo $PATH:查看环境变量地址