1、下载maven
Wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
2、解压
tar -zxvf apache-maven-3.2.5-bin.tar.gz
3、配置环境变量
(1)vi /etc/profile在其中添加以下几行
MAVEN_HOME=/usr/local/maven3(maven安装目录,也不一定就是这个目录,可自选别的目录)
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin
(2)source /etc/profile使环境变量生效。
注释:我安装好的不用配置,该文件里有
4、验证
Mvn -v
如果安装成功会打印如下内容
Apache Maven 3.2.5 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T04:58:10+08:00)
Maven home: /usr/local/maven3
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-35-generic", arch: "amd64", family: "unix"
注意:验证时如果出现bash: /opt/java/maven/bin/mvn: Permission denied
那就是没有权限
解决方法:chmod a+x/usr/local/maven3/bin/mvn 添加权限即可