下载Maven安装文件,(http://maven.apache.org/download.html)如:apache-maven-3.5.0-bin.zip,然后解压到本地目录。
打开 .bash_profile 文件,基本在/Users/macintosh/.bash_profile 路径。
接着在文件中添加(灵活应用,M2_HOME为文件解压后路径):
export M2_HOME=/Library/Java/apache-maven-3.5.0
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
在终端中运行
mvn –version
命令,检查Maven安装:终端显示:
Macintoshs-MacBook-Pro:~ macintosh$ mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /Library/Java/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
则证明Maven配置环境成功。