在.bashrc下面添加环境变量:
export M2_HOME=/Users/lee/Application/apache-maven-3.0.3
export PATH=$PATH:$M2_HOME/bin
重新启动终端
echo $M2_HOME
/Users/lee/Application/apache-maven-3.0.3
mvn -v
报异常 java.lang.ClassNotFoundException: org.codehaus.classworlds.Launcher
网上找了很多解决方案,不是很理想,随之查看了mvn
which mvn
/usr/bin/mvn
查看mvn文件
vim mvn
发现如下(mac os原先装了maven2.0):
-classpath "${M2_HOME}"/boot/classworlds-*.jar \
这就好办了,修改maven3.0.3的boot下的plexus-classworlds-2.4.jar,改为classworlds-2.4.jar
接着
mvn -v
OK
Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
Maven home: /Users/lee/Application/apache-maven-3.0.3
Java version: 1.6.0_17, vendor: Apple Inc.
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: zh_CN, platform encoding: EUC_CN
OS name: "mac os x", version: "10.6.4", arch: "x86_64", family: "mac"