ubuntu 安装maven
1、下载maven文件
切换目录
root@ubuntu:~# cd /usr/local
下载文件
root@ubuntu:/usr/local# wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
--2019-08-15 17:41:12-- http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
正在解析主机 mirror.bit.edu.cn (mirror.bit.edu.cn)... 219.143.204.117, 202.204.80.77, 2001:da8:204:1::22
正在连接 mirror.bit.edu.cn (mirror.bit.edu.cn)|219.143.204.117|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 9136463 (8.7M) [application/octet-stream]
正在保存至: “apache-maven-3.6.1-bin.tar.gz”
apache-maven-3.6.1- 100%[===================>] 8.71M 1.38MB/s 用时 6.1s
2019-08-15 17:41:19 (1.44 MB/s) - 已保存 “apache-maven-3.6.1-bin.tar.gz” [9136463/9136463])
2、解压
root@ubuntu:/usr/local# tar -zxvf apache-maven-3.6.1-bin.tar.gz
apache-maven-3.6.1/README.txt
apache-maven-3.6.1/LICENSE
apache-maven-3.6.1/NOTICE
apache-maven-3.6.1/lib/
apache-maven-3.6.1/lib/slf4j-api.license
apache-maven-3.6.1/lib/checker-compat-qual.license
apache-maven-3.6.1/lib/jsr250-api.license
apache-maven-3.6.1/lib/jcl-over-slf4j.license
apache-maven-3.6.1/lib/org.eclipse.sisu.plexus.license
apache-maven-3.6.1/lib/animal-sniffer-annotations.license
apache-maven-3.6.1/lib/org.eclipse.sisu.inject.license
...................................
3、删除文件
root@ubuntu:/usr/local# rm apache-maven-3.6.1-bin.tar.gz
4、配置环境变量
root@ubuntu:/usr/local# sudo vim /etc/profile
写入
export M2_HOME=/usr/local/apache-maven-3.6.1
export PATH=${M2_HOME}/bin:$PATH
按ESC,输入':wq'保存退出
5、测试
然后通过source /etc/profile 命令使当前配置生效
root@ubuntu:~# source /etc/profile
root@ubuntu:~# mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T12:00:29-07:00)
Maven home: /usr/local/apache-maven-3.6.1
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /opt/jvm/jdk1.8.0_221/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-23-generic", arch: "amd64", family: "unix"
6、完成