Maven Install on Mac OS X

2019-01-05 06:39发布

I'm trying to install maven through the terminal by following these instructions.

So far I got this

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

This is probably a stupid question where do you go to find this?

18条回答
相关推荐>>
2楼-- · 2019-01-05 07:13

Open a TERMINAL window and check if you have it already installed.

Type:

$ mvn –version

And you should see:

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”

If you don't have Maven installed already, then here is how to download and install maven, and configure environment variables on Mac OS X: http://bitbybitblog.com/install-maven-mac/

查看更多
男人必须洒脱
3楼-- · 2019-01-05 07:20

This command brew install maven30 didn't work for me. Was complaining about a missing FORMULA. But the following command did work. I've got maven-3.0.5 installed.

brew install homebrew/versions/maven30

This is for Mac OS X 10.9 aka Mavericks.

查看更多
对你真心纯属浪费
4楼-- · 2019-01-05 07:21

If you don't want to install Homebrew only for install Maven you could simply do this:

  1. Download the binary Maven and extract the zip

  2. Launch the Terminal and type this command:

    sudo ln -s /path_to_maven_folder/bin/mvn /usr/bin/mvn

You can find more details on this post.

查看更多
Deceive 欺骗
5楼-- · 2019-01-05 07:26

OS X prior to Mavericks (10.9) actually comes with Maven 3 built in.

If you're on OS X Lion, you won't have java installed by default. Just run java by itself and it'll prompt you to install it.

Assuming qualifications are met, run mvn -version and see some output like this:

Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
Maven home: /usr/share/maven
Java version: 1.6.0_29, 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.7.2", arch: "x86_64", family: "mac"
查看更多
迷人小祖宗
6楼-- · 2019-01-05 07:26

This worked for me:

$ vim .bash_profile

export JAVA_HOME=$(/usr/libexec/java_home)

$ source .bash_profile

credit: http://www.mkyong.com/java/maven-java_home-is-not-defined-correctly-on-mac-osx/

查看更多
太酷不给撩
7楼-- · 2019-01-05 07:28

Just a brief addition; if you want to install a specific version on MacOS using Homebrew 1.5.2, you can install it the following way:

  1. brew update
  2. brew search maven

This will give you maven versions available in homebrew

  1. brew install maven@3.3

[If you want to install maven 3.3.]

查看更多
登录 后发表回答