首先从官网上http://maven.apache.org/下载最新版Maven。我用的是apache-maven-3.0.4-bin.tar.gz。将下载后的文件拷贝到 /usr/local/目录下。
1、执行tar -zxvfapache-maven-3.0.4-bin.tar.gz命令解压文件
2、解压后会生成apache-maven-3.0.4目录,删除apache-maven-3.0.4-bin.tar.gz压缩包文件
3、执行ln -sapache-maven-3.0.4apache-maven(为Maven做一个软链接,方便以后升级)
export M2_HOME=/usr/local/apache-maven
PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE ...
5、保存并退出VI编辑器,执行source /etc/profile命令使改动生效
6、执行mvn -v命令,如出现如下内容表示安装配置成功
[root@xg /]# mvn -v
Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
Maven home: /usr/local/apache-maven
Java version: 1.6.0_33,vendor: Sun Microsystems Inc.
Java home: /usr/local/jdk1.6.0_33/jre
Default locale: zh_CN,platform encoding: UTF-8 OS name: "linux",version: "2.6.32-279.2.1.el6.x86_64",arch: "amd64",family: "unix"