yum -y install wget
cd /usr
mkdir ./maven
cd ./maven
wget https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.tar.gz --no-check-certificate
tar -zxvf apache-maven-3.9.1-bin.tar.gz
mv apache-maven-3.9.1 maven-3.9.1
mkdir -p /m2/repository
vim ./maven-3.9.1/conf/settings.xml
输入i,进入编辑模式,加入以下配置
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<localRepository>/m2/repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
</profiles>
</settings>
:wq
vim /etc/profile
MAVEN_HOME=/usr/local/maven/maven-3.9.1
PATH=$MAVEN_HOME/bin:$PATH
export MAVEN_HOME PATH
:wq
source /etc/profile
mvn -v