Maven Install on Mac OS X
Disclaimer: Here is a complete answer taking the last version of OS X (10.9 AKA Mavericks) into account. I am aware that everything I compiled in this answer is already present in the page, but having it clearly in one answer makes it a lot clearer.
First of all, with previous versions of OS X, Maven is installed by default. If Java is missing running you@host:~ $ java in a terminal will prompt you for the Java installation.
With Mac OS X 10.9 (Mavericks), Maven is not installed by default anymore. Different options are then possible:
Using Homebrew:
- you@host:~$ brew install maven will install Maven 3.1 which might cause issues
- you@host:~$ brew install maven30 will install Maven 3.0 which should be better
Using Macports: (I did not test this)
- you@host:~$ sudo port install maven3 will Install Maven 3.0.5
- you@host:~$ sudo port select –set maven maven3 selects that version of Maven
- Installing by hand:
- Download Maven from its homepage
- Follow the installation instructions:
- Extract the distribution archive, i.e. apache-maven-3.1.1-bin.tar.gz to the directory you wish to install Maven 3.1.1. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.1.1 will be created from the archive.
- In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1.
- Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.
- Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS=”-Xms256m -Xmx512m”. This environment variable can be used to supply extra options to Maven.
- Add M2 environment variable to your path, e.g. export PATH=
M2: PATH. - Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=
(/usr/libexec/javahome?v1.8)andthat JAVA_HOME/bin is in your PATH environment variable (although that might not be necessary with the latest Mac OS X versions and the Oracle JDK). - Run mvn –version to verify that it is correctly installed.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。