一、安装maven
1. 创建 /usr/local/maven 目录
mkdir /usr/local/maven
2. 进入 /usr/local/maven 目录,并下载 apache-maven-3.6.3
cd /usr/local/maven
wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
3. 解压 apache-maven-3.6.3-bin.tar.gz
tar -zxvf apache-maven-3.6.3-bin.tar.gz
4. 配置环境变量,在末尾添加以下内容
vi /etc/profile
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
5. 加载配置
source /etc/profile
6. 查看
mvn -v
二、修改配置
1. 创建 /usr/local/maven/repository 目录
mkdir /usr/local/maven/repository
2. 修改 /usr/local/maven/apache-maven-3.6.3/conf/settings.xml 文件
vim /usr/local/maven/apache-maven-3.6.3/conf/settings.xml
3. 添加以下配置
<!--本地仓库目录 -->
<localRepository>/usr/local/maven/repository</localRepository>
<!--添加阿里云镜像仓库 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<!-- https://maven.aliyun.com/repository/public/ -->
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>