1.首先确保已经安装了jdk
2.下载3.0.5版本
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
wget http://learning.happymmall.com/maven/apache-maven-3.0.5-bin.tar.gz
[root@localhost usr]# wget
http://learning.happymmall.com/maven/apache-maven-3.0.5-bin.tar.gz
--2018-02-02 11:08:27--
http://learning.happymmall.com/maven/apache-maven-3.0.5-bin.tar.gz
正在解析主机
learning.happymmall.com... 182.92.82.103
Connecting to
learning.happymmall.com|182.92.82.103|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:5144659 (4.9M) [text/html]
Saving to: `apache-maven-3.0.5-bin.tar.gz'
35% [============> ] 1,841,856 65.2K/s eta 65s
3.通过tar或者unzip解压缩
tar -zxvf apache-maven-3.0.5-bin.tar.gz
4.配置环境变量
sudo vim /etc/profile 最下面添加maven的环境变量
export MAVEN_HOME=/usr/apache-maven-3.0.5
注:maven_home为maven加压缩后的位置,不一定是在usr目录
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
执行:
source /etc/profile
使其生效
5.执行 mvn -version,进行验证
[root@localhost ~]# mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:28+0800)
Maven home: /usr/apache-maven-3.0.5
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_80/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "2.6.18-308.el5", arch: "amd64", family: "unix"