- Maven下载地址:http://maven.apache.org/download.cgi,这里所用的版本号为3.6.0
- 下载下来的压缩包上传到Centos中,并对压缩包进行解压:
tar zxf apache-maven-3.6.0-bin.tar.gz
mv apache-maven-3.6.0 maven
- 配置maven环境变量
vim /etc/profile
添加环境变量
export JAVA_HOME=/root/jdk1.8.0_181
export MAVEN_HOME=/root/maven
export PATH=$JAVAP_HOME/bin:$PATH
export PATH=$MAVEN_HOME/bin:$PATH
- 执行命令使环境变量生效,并验证版本
[root@localhost etc]# source profile
[root@localhost etc]# mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: /root/maven
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /root/jdk1.8.0_181/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.el7.x86_64", arch: "amd64", family: "unix"
- 打开maven配置文件,修改仓库为阿里云的仓库
[root@localhost ~]# cd maven/conf/
[root@localhost conf]# ls
logging settings.xml toolchains.xml
[root@localhost conf]# vim settings.xml
修改内容
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
- 配置本地的仓库
<localRepository>/root/repo</localRepository>