Mac OS X 安装Maven:
-
下载 Maven, 并解压到某个目录。例如/Users/robbie/apache-maven-3.3.3
-
打开
Terminal
,输入以下命令,设置Maven classpath
$ vi ~/.bash_profile
添加下列两行代码,之后保存并退出
Vi
:export M2_HOME=/Users/robbie/apache-maven-3.3.3 export PATH=$PATH:$M2_HOME/bin
![](http://upload-images.jianshu.io/upload_images/420187-6947fe0af3933d3d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
bash_profile
-
输入命令以使
bash_profile
生效$ source ~/.bash_profile
-
输入
mvn -v
查看Maven
是否安装成功 -
如果遇到以下异常,重新编辑
bash_profile
文件,增加export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home
后,并重新运行$ source ~/.bash_profile
即可。
![](http://upload-images.jianshu.io/upload_images/420187-21014c26d4442c05.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
exception
![](http://upload-images.jianshu.io/upload_images/420187-0b45f0a40e8da2f5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/420187-fee2d6db07d70ca8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
参考: http://www.jianshu.com/p/191685a33786