Jenkins准备篇05-阿里云Centos7服务器安装Maven

上篇基于“Git + Maven + Jenkins 实现自动化部署”已安装好必备的工具git,那么本篇主要针对“阿里云Centos7服务器安装Maven”进行讲解,希望感兴趣的小伙伴可以坚持看下去同时欢迎提出宝贵的意见让我们一起进步!

Maven介绍

是一个项目管理工具,可以对 Java 项目进行构建、依赖管理

第一步:下载Maven安装包

(1)官网安装包地址:http://maven.apache.org/download.cgi
(2)找到“apache-maven-3.6.3-bin.tar.gz”,点击“下载”按钮,跳转出下载链接,复制链接
(3)利用wget下载安装包
(4)linux命令为:wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

[root@iZ2zebjpjfqq58nc6ul6hnZ package]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
--2020-05-10 19:21:42--  https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9506321 (9.1M) [application/x-gzip]
Saving to: ‘apache-maven-3.6.3-bin.tar.gz’

100%[==============================================================================================>] 9,506,321   --.-K/s   in 0.08s   

2020-05-10 19:21:42 (113 MB/s) - ‘apache-maven-3.6.3-bin.tar.gz’ saved [9506321/9506321]
第二步:进入Maven安装包目录并解压

(1)linux命令为:tar -zxvf apache-maven-3.6.3-bin.tar.gz

第三步:配置环境变量

(1)linux命令为:vim /etc/profile进入文件profile文件进行配置环境变量
(2)M2_HOMEMaven的安装路径,每个人路径都有所不同
(3)特别注意:配置JAVA_HOME要与/usr/java/目录下jdk名称保持一致

底部追加的内容为:
export M2_HOME=/root/package/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin
第四步:重启加载profile让系统文件生效

(1)linux命令为:source /etc/profile

第五步: 验证是否安装成功

(1)linux命令为:mvn -version

[root@iZ2zebjpjfqq58nc6ul6hnZ ~]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /root/package/apache-maven-3.6.3
Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_251-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.21.3.el7.x86_64", arch: "amd64", family: "unix"

你可能感兴趣的:(Jenkins准备篇05-阿里云Centos7服务器安装Maven)