centos7下部署maven环境

centos7下部署maven环境

1.安装前提
基于jdk,要高于1.7。
执行java -version查看是否已安装jdk,如未安装则需要安装java环境
2.下载maven
官方下载地址:http://maven.apache.org/download.cgi
执行wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz下载

[root@nexus ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
--2020-03-06 01:22:08--  https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9506321 (9.1M) [application/octet-stream]
正在保存至: “apache-maven-3.8.8-bin.tar.gz”
100%[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++===============================================================================================================>] 9,506,321   3.16MB/s 用时 1.4s   

2020-03-06 01:24:06 (3.16 MB/s) - 已保存 “apache-maven-3.8.8-bin.tar.gz” [9506321/9506321])

3.解压maven包并进入maven目录
解压maven包至指定目录/usr/local/
tar xvf apache-maven-3.8.8-bin.tar.gz -C /usr/local/
cd /usr/local/apache-maven-3.8.8
4.配置环境变量并验证
vim /etc/profile
增加以下几行内容,source /etc/profile,使环境变量生效,mvn -v查看是否安装成功

[root@nexus local]# vim /etc/profile

MAVEN_HOME=/usr/local/apache-maven-3.8.8
PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
export JAVA_HOME MAVEN_HOME PATH

[root@nexus local]# source /etc/profile
[root@nexus local]# mvn -v
Apache Maven 3.8.8 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/apache-maven-3.6.3
Java version: 1.8.0_161, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_161/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"

你可能感兴趣的:(centos7下部署maven环境)