1、获取安装包并解压
cd /usr/local
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -zxvf apache-maven-3.6.3-bin.tar.gz
2、配置环境变量,添加export
vim /etc/profile
export MAVEN_HOME=/usr/local/maven
export PATH=${MAVEN_HOME}/bin:${PATH}
source /etc/profile
mvn -v
vim ~/.bash_profile
JAVA_HOME 和 M2_HOME 都设置成自己文件的位置
source ~/.bash_profile
3、添加阿里云镜像
vim $MAVEN_HOME/conf/settings.xm
添加以下镜像配置
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>central-repository</id>
<mirrorOf>*</mirrorOf>
<name>Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</mirror>
</mirrors>