如果有安裝XCode, XCode會自動幫你安裝Maven, 安裝在/usr/share/java/
安裝3.0.3
- 到http://maven.apache.org/download.html 下載maven 3.0.3
- 將apache-maven-3.0.3-bin.tar.gz解壓縮到/usr/share/java
- 移除/usr/share下的softlink maven
- ln -s /usr/share/java/apache-maven-3.0.3 /usr/share/maven
- 修改~/.profile 設定M3_HOME=/usr/share/java/apache-maven-3.0.3
注意事項
不能同時設M2_HOME與M3_HOME兩個環境變數, 不然執行maven會出現以下的exceptionException in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Installing Maven 3 on OS X1. Install Mac Ports2. Install Maven 3Open a terminal and type the following:sudo port install maven3 maven_selectsudo maven_select maven3