0%

centos 7 安装 maven

下载

官网下载地址:http://maven.apache.org/download.cgi

20200520232525

复制链接地址:https://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

使用命令下载:wget https://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

安装

创建 maven 的安装目录,使用命令 mkdir -p /usr/local/maven3

解压安装包,使用命令 tar -zxvf apache-maven-3.6.3-bin.tar.gz

将解压文件拷贝到指定目录:

1
2
3
[root@localhost apache-maven-3.6.3]# cp -r * /usr/local/maven3/
[root@localhost apache-maven-3.6.3]# ls /usr/local/maven3/
bin boot conf lib LICENSE NOTICE README.txt

配置环境变量

修改配置文件【/etc/profile】,添加内容:

1
2
3
## maven
export M2_HOME=/usr/local/maven3
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin

重启加载 profile 让修改生效,使用命令 source /etc/profile

验证 maven 是否安装成功

使用命令 mvn -version

1
2
3
4
5
6
[root@localhost ~]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/maven3
Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1062.18.1.el7.x86_64", arch: "amd64", family: "unix"
您的支持是我最大的动力!