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 解压安装包
tar -xzvf apache-maven-3.6.3-bin.tar.gz
mv apache-maven-3.6.3 /opt/myprogram/
3 在maven配置文件中添加阿里云镜像
vi /opt/myprogram/apache-maven-3.6.3/conf/settings.xml
在标签<mirrors>里添加内容:
<mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | --> <mirror> <id>aliyun-maven</id> <mirrorOf>*</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors>
4 配置maven环境变量
vi /etc/profile
添加以下内容
export M2_HOME=/opt/myprogram/apache-maven-3.6.3 export PATH=$PATH:$M2_HOME/bin
使配置生效
source /etc/profile