1、从官方网站下载maven文件包
官方下载网站:https://maven.apache.org/download.cgi
2、创建文件夹解压文件
将下载好的安装包,放到创建的目录下,并解压
a、创建/app/maven文件
bash
mkdir /app/maven
b、解压文件
bash
tar -zxvf apache-maven-3.9.6-bin.tar.gz
c、配置settings.conf文件
a) maven 仓库地址
bash
<localRepository>/app/maven/repo</localRepository>
b) maven镜像
bash
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
3、配置/etc/profile
打开文件
bash
vim /etc/profile
将配置放进里面
bash
# maven
export MAVEN_HOME=/app/maven/apache-maven-3.9.6
export PATH=$PATH:$MAVEN_HOME/bin
重新加载文件
bash
source /etc/profile
测试
bash
mvn -version
bash
[root@test apache-maven-3.9.6]# mvn -version
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /app/maven/apache-maven-3.9.6
Java version: 1.8.0_401, vendor: Oracle Corporation, runtime: /app/java/jdk1.8.0_401/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1127.19.1.el7.x86_64", arch: "amd64", family: "unix"