1.下载
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
2.解压
#### 创建maven目录
mkdir /usr/local/maven
#### 解压
tar zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/local/maven/
3.设置环境变量
vim /etc/profile
#### 在最后面添加如下
# maven
MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3
export PATH=${MAVEN_HOME}/bin:${PATH}
#### 使配置生效
source /etc/profile
#### 查看安装版本
mvn -v
4.设置国内源
vim /usr/local/maven/apache-maven-3.6.3/conf/settings.xml
#### 在<mirrors></mirrors>之间添加如下
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
5.指定jar目录
#### 指定下载jar包目录
#### 找到<localRepository>/path/to/local/repo</localRepository>添加如下
<localRepository>/usr/local/maven/repository</localRepository>