1.下载maven http://maven.apache.org/download.cgi
我下载的是:apache-maven-3.3.9-bin.tar.gz
解压:tar -zxvf apache-maven-3.3.9-bin.tar.gz
拷贝:cp -r apache-maven-3.3.9 /opt/maven
2、修改配置文件
#vi /etc/profile
添加下面内容:
#maven
M2_HOME=/opt/mavenPATH=$PATH:$M2_HOME/binexport M2_HOME PATH保存退出vi编辑器
然后使环境变量生效:
#source /etc/profile 或注销重新登录
若成功,输入#mvn -version后显示:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /opt/mavenJava version: 1.7.0_55, vendor: Oracle CorporationJava home: /usr/lib/jvm/java/jreDefault locale: en_US, platform encoding: UTF-8OS name: "linux", version: "2.6.32-358.el6.x86_64", arch: "amd64", family: "unix"mvn -v运行成功后,会在/home/”某用户" 路径下生成.m2文件夹,这种由"."开头的文件在Linux里默认为隐藏文件,要显示隐藏文件才能看到。