官网下载: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
下载完成后解压
1 2 3 4 | [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.添加阿里云镜像 |
修改仓库目录
1 | < localRepository >/m2/repository</ localRepository > |
替换阿里云镜像(155行)
1 2 3 4 5 6 | < mirror > < id >alimaven</ id > < name >aliyun maven</ name > < mirrorOf >central</ mirrorOf > </ mirror > |
添加环境变量
1 2 3 4 5 6 7 8 9 10 11 | [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" |