1、进入/usr/local目录下,新建maven文件夹
cd /usr/local
mkdir maven
2、将下载好的maven压缩文件放置在linux的/usr/local/maven文件夹下,解压该压缩文件
tar -zxvf apache-maven-3.6.1-bin.tar.gz
3、在apache-maven-3.6.1同级目录创建maven依赖文件夹
cd /usr/local/maven
mkdir repository
4、更改maven配置文件
cd /usr/local/maven/apache-maven-3.6.1/conf
修改settings.xml文件内容为
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>/usr/local/maven/repository</localRepository> <pluginGroups> </pluginGroups> <proxies> </proxies> <servers> </servers> <mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors> <profiles> </profiles> </settings>
5、配置环境变量
vim /etc/profile
内容最后加入
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.1
export PATH=${PATH}:${MAVEN_HOME}/bin
保存退出
6、让profile文件即时生效
source /etc/profile
7、检查maven是否安装成功
mvn -v
出现上图表示安装成功
O(∩_∩)O开心就好O(∩_∩)O