安装
注意:安装前务必先安装好JDK(Java环境)
1.获取安装资源 http://maven.apache.org/download.cgi

或使用命令 wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz 下载
2.解压得到的安装包 tar -zxvf apache-maven-3.6.0-bin.tar.gz
3.配置环境变量 vim /etc/profile ,在末尾追加。
#apache-maven-3.6.0
export M2_HOME=/soft/apache-maven-3.6.0
export PATH=$PATH:$M2_HOME/bin
保存退出后,使用 source /etc/profile 让配置生效
maven配置
1.编辑配置文件 vim /soft/apache-maven-3.6.0/conf/settings.xml
2.指定 maven 本地仓库目录 <localRepository>/data/maven/repository</localRepository>

3.指定远程仓库目录,这里以 阿里云 为例
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

验证
1.使用 mvn -v 命令验证是否成功安装,成功安装后如下图所示

网友评论