环境信息

CentOS Linux release 7.4.1708 (Core)
maven 3.3.9

安装Maven

  1. 创建文件夹

    [vagrant@localhost ~]$ mkdir maven
    [vagrant@localhost ~]$ cd maven
  2. 下载Maven

    wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

    下载了安装包apache-maven-3.3.9-bin.tar.gz

    [vagrant@localhost maven]$ ll
    总用量 8296
    -rw-rw-r-- 1 vagrant vagrant 8491533 1118 2015 apache-maven-3.3.9-bin.tar.gz
  3. 解压安装包

tar -zxvf apache-maven-3.3.9-bin.tar.gz

配置环境变量

  1. 使用vim打开/etc/profile文件

    sudo vim /etc/profile
  2. 在/etc/profile文件末尾增加以下配置

    
    #maven environment  
    
    export M2_HOME=/home/vagrant/maven/apache-maven-3.3.9  
    export PATH=$PATH:${M2_HOME}/bin
  3. 使配置生效

source /etc/profile

测试安装

运行命令mvn -v

[vagrant@localhost apache-maven-3.3.9]$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /home/vagrant/maven/apache-maven-3.3.9
Java version: 1.8.0_172, vendor: Oracle Corporation
Java home: /home/vagrant/java/jdk1.8.0_172/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-229.el7.x86_64", arch: "amd64", family: "unix"
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐