[root@localhost ~]# wget http://mirror.cc.columbia.edu/pub/ software/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz [root@localhost ~]# tar xzf apache-maven-3.1.1-bin.tar.gz -C /usr/local [root@localhost ~]# cd /usr/local [root@localhost ~]# ln -s apache-maven-3.1.1 maven上面的wget是从后面给定的URL中下载maven,当然,你也可以直接访问http://maven.apache.org/download.cgi手动下载。第二行命令是将下载下来的tar.gz包解压到/usr/local(tar默认将文件解压到当前目录,加了-C参数之后,是将解压的文件存放到/usr/local中)
当然,解压完下载下来的maven包是现在还不能启用,需要在PATH里面设置一下路径,如下:
[root@localhost ~]# vim /etc/profile.d/maven.sh export MAVEN_HOME=/usr/local/maven export PATH=${MAVEN_HOME}/bin:${PATH}设置好Maven的路径之后,需要运行下面的命令
[root@localhost ~]# source /etc/profile.d/maven.sh
[root@localhost ~]# vim /etc/profile MAVEN_HOME=//usr/local/maven export MAVEN_HOME export PATH=${PATH}:${MAVEN_HOME}/bin设置好Maven的路径之后,需要运行下面的命令
[root@localhost ~]# source /etc/profile使得上面设置的环境变量立即生效。
[root@localhost ~]# mvn -v Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:28+0800) Maven home: /usr/local/maven java version: 1.6.0_24, vendor: Sun Microsystems Inc. java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-358.14.1.el6.x86_64", arch: "amd64", family: "unix"如果出现了上面类似的字段,说明Maven安装及配置完了!
你也就运行mvn -version
[root@localhost ~]# mvn -version Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:28+0800) Maven home: /usr/local/maven java version: 1.6.0_24, vendor: Sun Microsystems Inc. java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-358.14.1.el6.x86_64", arch: "amd64", family: "unix"和上面的效果是一样的。