安装java环境
yum -y install java-1.8.0-openjdk.x86_64
下载
wget http://archive.apache.org/dist/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz
tar xzvf apache-maven-3.8.2-bin.tar.gz
mv apache-maven-3.8.2 /usr/local/maven3
添加环境
vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/jre
export MAVEN_HOME=/usr/local/maven3
export M2_HOME=/usr/local/maven3
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
source /etc/profile
检测是否成功
mvn -version
Java version: 1.8.0_292, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.31.1.el7.x86_64", arch: "amd64", family: "unix"