官网下载:https://maven.apache.org/download.cgi
当前最新版本
https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
下载完成后解压
[root@dlb home]# tar -zxvf apache-maven-3.8.6-bin.tar.gz -C /home/maven-3.8.6 #解压
[root@dlb home]# cd maven-3.8.6/conf/
[root@dlb conf]# mkdir -p /m2/repository #创建maven的仓库目录
[root@dlb conf]# vim settings.xml #修改配置文件1.修改仓库目录。2.添加阿里云镜像
修改仓库目录
<localRepository>/m2/repository</localRepository>
替换阿里云镜像(155行)
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
添加环境变量
[root@dlb conf]# vim /etc/profile # 修改环境变量
export M2_HOME=/home/maven-3.8.6
export PATH=$PATH:$M2_HOME/bin
[root@dlb conf]# source /etc/profile #更新资源
[root@dlb conf]# mvn -v #检验是否安装好
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/maven-3.8.6
Java version: 11.0.12, vendor: Oracle Corporation, runtime: /usr/java/jdk-11.0.12
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1127.19.1.el7.x86_64", arch: "amd64", family: "unix"
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/273908.html