一 、下载maven
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
如果wget无法使用先安装wget
yum -y install wget
如果安装失败先执行下面命令
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
如果还下载失败,复制https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz去浏览器下载,通过xftp等工具上传到服务器
二、解压
tar -zxvf apache-maven-3.6.3-bin.tar.gz
三 、配置环境变量
vi /etc/profile
#你的maven路径
MAVEN_HOME=/opt/maven/apache-maven-3.6.1
export PATH=${MAVEN_HOME}/bin:${PATH}
source /etc/profile
五、换成阿里云镜像
找到你解压的maven文件中的settings.xml文件
vi /etc/apache-maven-3.6.3/conf/settings.xml
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<localRepository>/home/MyRepository</localRepository>
cd /home
mkdir MyRepository