mac下 安装maven


在mac上安装maven,网上都说的是xcode自动安装了maven,可是我的就是没有。mvn命令找不到。于是自己在网上搜索问题,好多给的答案都不对,最终在下面的网站上找到了。
http://www.mkyong.com/maven/install-maven-on-mac-osx/  

很不错。搞定了。



2. Install Maven Manually

After the upgrade of Mac OS X Mavericks, Maven was removed (no idea why). So, You have to install it manually.

2.1 – Download Maven
Download the Maven, for example apache-maven-3.1.1-bin.tar.gz. Extracts it,

tar -xvf apache-maven-3.1.1-bin.tar.gz

$pwd
/Users/mkyong/apache-maven-3.1.1

2.2 – Set Maven command in environment variable.
Update ~/. bash_profile – create this file if doesn’t exist.

$ vim ~/.bash_profile

~/.bash_profile

export M2_HOME=/Users/mkyong/apache-maven-3.1.1
export PATH=$PATH:$M2_HOME/bin

Restart the terminal. Test it.

$mvn -version

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 23:22:22+0800)
Maven home: /Users/mkyong/apache-maven-3.1.1
Java version: 1.7.0_05, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"

3. Post Configuration

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

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

$vim /usr/mkyong/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/.


你可能感兴趣的:(mac下 手动安装maven)