一、准备安装包
下载地址:https://maven.apache.org/download.cgi
选择Binary tar.gz archive的链接,虽然安装包只有8M但是下载速度很慢
下载完后使用winscp上传到服务器
二 、安装
解压安装包
tar -zxvf apache-maven-3.8.8-bin.tar.gz
将解压后的文件夹移动到/opt目录
mv apache-maven-3.8.8 /opt/
配置环境变量
vim /etc/profile
文件末尾追加
export MAVEN_HOME=/opt/apache-maven-3.8.8
export PATH=$PATH:$MAVEN_HOME/bin
使环境变量立即生效
source /etc/profile
执行查看版本命令
mvn -v
root@qiko:~# mvn -v
Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Maven home: /opt/apache-maven-3.8.8
Java version: 1.8.0_144, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_144/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-58-generic", arch: "amd64", family: "unix"
如果没有安装JDK会有如下提示,JDK的安装请查看Linux安装JDK1.8
root@qiko:~# mvn -v
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.