宦子萱 发表于 2016-5-16 09:27:33

mac maven

How To Install Maven On Mac OSX

http://0.gravatar.com/avatar/622c70d2908e68ecc070ca6754245bb2?s=40&d=http%3A%2F%2Fwww.mkyong.com%2Fwp-content%2Fthemes%2Fmkyongnew%2Fimages%2Favatar-guest.jpg%3Fs%3D40&r=G

Posted on July 16, 2012 ,     Last modified : December 13, 2012
By mkyong






Since Lion 10.7.1 (correct me if wrong), Mac OS X comes with Apache Maven 3 built in, and can be located at/usr/share/maven.

1. Maven Verification

In terminal, issue the command mvn -version.

$mvn -version
 
Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
Maven home: /usr/share/maven
Java version: 1.6.0_33, 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.4", arch: "x86_64", family: "mac"




 

2. So, where is Maven installed?

A quick check with whereis command :

$ whereis mvn
/usr/bin/mvn




$ cd /usr/bin
$$ ls -ls | grep mvn
8 lrwxr-xr-x   1 root   wheel      24 May 23 15:57 mvn -> /usr/share/maven/bin/mvn




By default, Maven is installed at /usr/share/maven.

3. Change Maven local repository

A common post-installation for Maven, change the local repository to another location.

$sudo vim /usr/share/maven/conf/settings.xml




settings.xml

<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ~/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>/Users/mkyong//maven/repo/</localRepository>




Above example changed the default repository from ~/.m2/repository to /Users/mkyong//maven/repo/.

Note
For older Mac OS, you need to download, extra, and configure the environment manually. Please refer to this guide.
页: [1]
查看完整版本: mac maven