linux安装maven

1、下载(最新版下载地址从官网获取:https://maven.apache.org/download.cgi)

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

2、解压

tar xzvf apachemaven3.3.9bin.tar.gz

3、将解压后的文件夹复制到安装路径

cp -r apache-maven-3.3.9 /usr/local/apache-maven

4、配置环境变量(首先要配置JAVA_HOME,通过echo $JAVA_HOME查看是否已配置)

vim /etc/profile

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export M2_HOME=/usr/local/apache-maven
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

5、查看是否配置成功(Confirm with mvn -v in a new shell.)

mvn -v

出现类似下面的信息说明配置成功

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.77-0.b03.el6_7.x86_64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: “linux”, version: “2.6.32-431.23.3.el6.x86_64”, arch: “amd64”, family: “unix”

 

安装参考官网文档:https://maven.apache.org/install.html