1.安装java环境
参考:CenterOS7安装java环境 - jupiter's blog (inat.top)
2.下载maven并解压
下载地址:https://maven.apache.org/download.cgi
wget https://dlcdn.apache.org/maven/maven-3/3.9.8/binaries/apache-maven-3.9.8-bin.tar.gz
tar xzvf apache-maven-3.9.8-bin.tar.gz
- 创建本地仓库文件夹
cd apache-maven-3.9.8
mkdir repository
3.配置环境变量
vim ~/.bashrc
# 配置maven_home和Path环境变量
export MAVEN_HOME=/software/apache-maven-3.9.8
export PATH=$PATH:$MAVEN_HOME/bin
# 配置本地仓库地址环境变量
export M2_HOME=/software/apache-maven-3.9.8/repository
source ~/.bashrc
4.配置镜像源
vim conf/settings.xml
# 在<mirrors></mirrors>标签中添加 mirror 子节点
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
5.检查是否安装成功
[root@localhost apache-maven-3.9.8]# mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: /software/apache-maven-3.9.8
Java version: 17.0.11, vendor: Eclipse Adoptium, runtime: /software/jdk17
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.119.1.el7.x86_64", arch: "amd64", family: "unix"
评论 (0)