确保安装了JDK
压缩包和解压包的存放目录均为/usr/local/src/
环境变量在/root/.bash_profile (自己添加)
1. 进入/usr/local/src/目录
cd /usr/local/src/
2. 下载maven
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
3. 解压maven到当前目录
tar -zvxf apache-maven-3.5.2-bin.tar.gz
4. 配置环境变量
vim /root/.bash_profile
# 添加如下内容 注意路径修改成自己的路径
# Maven
MAVEN_HOME=/usr/local/src/apache-maven-3.5.2
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME
export PATH
# 使其生效
source /root/.bash_profile
5. 查看是否安装成功
mvn -v
#出现以下内容说明安装成功
Maven home: /usr/local/src/apache-maven-3.5.2
Java version: 1.8.0_141, vendor: Oracle Corporation
Java home: /usr/local/src/jdk1.8.0_141/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-514.26.2.el7.x86_64", arch: "amd64", family: "unix"
网友评论