Install Maven on Mac OS X:
-
Download Maven , and extract to a directory. For example /Users/robbie/apache-maven-3.3.3
-
Open
Terminal
, enter the following command, setMaven classpath
$ vi ~/.bash_profile
Add the following two lines of code, then save and exit
Vi
:export M2_HOME=/Users/robbie/apache-maven-3.3.3 export PATH=$PATH:$M2_HOME/bin
-
Enter the command to
bash_profile
take effect$ source ~/.bash_profile
-
Enter to
mvn -v
seeMaven
if the installation is successful -
If you encounter the following exception, re-edit the
bash_profile
file, addexport JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home
it, and re-run it$ source ~/.bash_profile
.
Reference: http://www.jianshu.com/p/191685a33786