我正在尝试按照这些说明通过终端安装maven。
到目前为止我得到了这个:
export M2_HOME=/user/apple/apache-maven-3.0.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/usr/java/jdk1.6.0_22
你去哪儿找这个?
我正在尝试按照这些说明通过终端安装maven。
到目前为止我得到了这个:
export M2_HOME=/user/apple/apache-maven-3.0.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/usr/java/jdk1.6.0_22
你去哪儿找这个?
当前回答
您可以使用自制软件安装maven。命令为 $ brew安装maven
其他回答
当我最近升级到OS X Mavericks时,我的maven构建开始失败。所以我需要再次安装maven,因为它不是内置的。然后我试着输入命令:
brew install maven
它可以工作,但它安装了maven的3.1.1版本,这对一些用户(https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound)造成了一些问题。因此,如果遇到同样的问题,您可能希望安装较早的Maven版本3.0.5。要在Homebrew中做到这一点,你必须执行以下命令:
brew install https://raw.github.com/Homebrew/homebrew-versions/master/maven30.rb
就是这样,它将使用不同的Homebrew公式,这将为您提供maven 3.0.5。
安装Maven的简单方法。
打开终端
Finder -> Go -> Utilities -> Terminal
使用下面的命令安装Homebrew
ruby -e "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后安装maven
Brew安装专家
免责声明:这是一个完整的答案,考虑到OS X的最后一个版本(10.9 AKA Mavericks)。我知道我在这个答案中编译的所有内容都已经出现在页面中,但在一个答案中清楚地表达出来会让它更清楚。
首先,对于以前的OS X版本,Maven是默认安装的。如果没有Java,在终端上运行you@host:~ $ Java将提示您安装Java。
在Mac OS X 10.9 (Mavericks)中,Maven不再默认安装。然后可能有不同的选择:
Using Homebrew: you@host:~$ brew install maven will install latest Maven (3.5.2 on 02/01/2018) you@host:~$ brew install maven30 will install Maven 3.0 if needed Using Macports: (I did not test this) you@host:~$ sudo port install maven will install latest Maven (?) or: you@host:~$ sudo port install maven3 will Install Maven 3.0 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.3.9-bin.tar.gz to the directory you wish to install Maven 3.3.9. The subdirectory apache-maven-3.3.9 will be created from the archive. 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. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) and that $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). Add extracted apache-maven-3.3.9/bin to your $PATH Run mvn --version to verify that it is correctly installed.
在马华力号上,在终点站跑 xcode-select——安装 安装命令行工具。
打开TERMINAL窗口并检查是否已经安装了它。
类型:
$ mvn –version
你应该看到:
Apache Maven 3.0.2 (r1056850; 2011-01-09 01:58:10+0100)
Java version: 1.6.0_24, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: “mac os x”, version: “10.6.7″, arch: “x86_64″, family: “mac”
如果你还没有安装Maven,那么下面是如何下载和安装Maven,并在Mac OS X上配置环境变量:
http://bitbybitblog.com/install-maven-mac/