1.创建一个maven文件夹
[root@MiWiFi-R3-srv ~]# mkdir /usr/local/maven
- 1
2.上传apache-maven-3.5.0-bin.tar.gz到/usr/local/maven/目录下
链接: https://pan.baidu.com/s/1c6QDXW 密码: ymq2
3.解压
[root@MiWiFi-R3-srv ~]# tar -zxvf apache-maven-3.5.0-bin.tar.gz -C /usr/local/maven/
- 1
4.设置环境变量
[root@MiWiFi-R3-srv ~]# vim /etc/profile
- 1
在/etc/profile的文件末尾添加以下配置:
export M2_HOME=/usr/local/maven/apache-maven-3.3.9
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$M2_HOME/bin:$PATH
- 1
- 2
执行source命令让新配置立即生效:
[root@MiWiFi-R3-srv ~]# source /etc/profile
- 1
5.测试
[root@MiWiFi-R3-srv ~]# mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/maven/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /usr/local/java/jdk1.8.0_144/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix"