> For the complete documentation index, see [llms.txt](https://hezhiqiang-1.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hezhiqiang-1.gitbook.io/linux/soft/maven-install.md).

# Maven 安装

> 环境要求：
>
> * JDK

* [安装方法](https://hezhiqiang-1.gitbook.io/linux/soft/pages/-LyNL-5H48t_z8wq9DVU#安装方法)
* [脚本](https://hezhiqiang-1.gitbook.io/linux/soft/pages/-LyNL-5H48t_z8wq9DVU#脚本)

## 安装方法

安装步骤如下：

（1）下载

进入官网下载地址：<https://maven.apache.org/download.cgi> ，选择合适的版本下载。

我选择的是最新 Maven3 版本：<http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz>

（2）解压到本地

我个人喜欢存放在：`/opt/maven`

（3）设置环境变量

输入 `vi /etc/profile` ，添加环境变量如下：

```
# MAVEN 的根路径
export MAVEN_HOME=/opt/maven/apache-maven-3.5.2
export PATH=\$MAVEN_HOME/bin:\$PATH
```

执行 `source /etc/profile` ，立即生效

（4）检验是否安装成功，执行 `mvn -v` 命令

## 脚本

以上两种安装方式，我都写了脚本去执行：

\| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) |
