本地压缩包安装(推荐)
下载地址:https://maven.apache.org/download.cgi
# 将安装包移动到当前目录
cd /usr/local && mkdir maven && cd maven
# 在线下载(https://dlcdn.apache.org/maven/)
wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz
# 解压安装包
tar -zxvf apache-maven-3.8.4-bin.tar.gz
创建本地maven仓库
cd /usr/local/maven && mkdir repository && chmod -R 777 repository/
指定本地仓库地址和阿里镜像
配置文件地址:/usr/local/maven/apache-maven-3.8.4/conf
<localRepository>/usr/local/maven/repository</localRepository>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/
</url>
</mirror>
配置maven环境变量
vi /etc/profile # 添加如下内容并保存
# maven
export MAVEN_HOME=/usr/local/maven/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin
# 使环境变量生效
source /etc/profile