1,下载maven安装包进入/usr/local目录,用wget命令下载(此处以maven3.6.3版本为例),操作如下:,我来为大家科普一下关于linux 配置maven环境?下面希望有你要的答案,我们一起来看看吧!

linux 配置maven环境(CentOS7搭建maven环境)

linux 配置maven环境

1,下载maven安装包

进入/usr/local目录,用wget命令下载(此处以maven3.6.3版本为例),操作如下:

[root@localhost ~]# cd /usr/local/[root@localhost local]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz--2022-06-17 11:46:47-- http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:9506321 (9.1M) [application/octet-stream]正在保存至: “apache-maven-3.6.3-bin.tar.gz”

100%[===============================================================================================================================>] 9,506,321 2.44MB/s 用时 4.1s

2022-06-17 11:46:51 (2.21 MB/s) - 已保存 “apache-maven-3.6.3-bin.tar.gz” [9506321/9506321])

注:如果没有wget命令,执行以下命令进行安装:

[root@localhost maven]# yum install -y wget

2,解压maven安装包

1)新建目录,命令如下:

[root@localhost local]# mkdir maven

2)解压,命令如下:

[root@localhost local]# tar -zxvf apache-maven-3.6.3-bin.tar.gz

3)将解压maven文件拷贝到指定目录,命令如下:

[root@localhost local]# cd apache-maven-3.6.3/[root@localhost apache-maven-3.6.3]# cp -r * /usr/local/maven

3,配置环境:

1)配置环境变量,命令如下:

[root@localhost maven]# vim /etc/profile

添加如下内容:

MAVEN_HOME=/usr/local/maven export MAVEN_HOME export PATH=$MAVEN_HOME/bin:$PATH

wq保存

2)使环境变量生效,命令如下:

[root@localhost maven]# source /etc/profile

4,验证maven是否安装成功,命令如下:

[root@localhost maven]# mvn -version

显示maven版本信息即安装成功,即:Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)Maven home: /usr/local/mavenJava version: 1.8.0_241, vendor: Oracle Corporation, runtime: /usr/local/java/jdk1.8.0_241/jreDefault locale: zh_CN, platform encoding: UTF-8OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"

注:maven依赖jdk环境,如果没有java环境,参考如下链接安装:

http://www.toutiao.com/article/7100123382339076623/