1.用yum自动安装
yum install maven -y
配置阿里云镜像
vim /etc/maven/settings.xml ,mirrors节点下添加:
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
2.手动安装
下载maven
wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
解压
tar -zvxf apache-maven-3.6.3-bin.tar.gz
移动目录
mv apache-maven-3.6.3 /usr/local/maven
添加环境变量
vi /etc/profile
使其生效
source /etc/profile
配置阿里云镜像
安装包版本的maven的setting文件在安装包的conf下面,添加下面配置
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>