1、下载maven
地址: https://maven.apache.org/download.cgi
下载完解压
2、 配置环境变量
vim ~/.bash_profile
export M2_HOME=/Users/wyh/apache-maven-3.6.0/
export PATH=$PATH:$M2_HOME/bin
生效修改过文件 source ~/.bash_profile
3、验证
mav -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: /Users/wyh/apache-maven-3.6.0
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"
如果失败
echo $M2_HOME :查看maven的环境变量
echo $PATH:查看环境变量地址