Ubuntu 安装 Maven

Maven

下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

更多版本下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/maven/

安装 & 配置

下载:

1
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

解压缩

1
$ tar zxvf apache-maven-3.6.1-bin.tar.gz

转移至固定目录(可根据情况调整)

1
2
3
$ # 推荐放在 /usr/local/maven 下
$ mkdir /usr/local/maven
$ sudo mv apache-maven-3.6.1 /usr/local/maven/

配置环境变量

1
2
3
4
5
$ # 这一步的目的是让系统可以通过 PATH 找到 maven 的可执行文件
$ echo "MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3" >> ~/.bashrc
$ echo "PATH=\${PATH}:\${MAVEN_HOME}/bin" >> ~/.bashrc
$ echo "export PATH" >> ~/.bashrc
$ source ~/.bashrc

检查是否安装成功

1
2
3
4
5
$ mvn -v
Maven home: /usr/local/maven/apache-maven-3.6.3
Java version: 1.8.0_242, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-62-generic", arch: "amd64", family: "unix"
----本文结束 感谢您的阅读----