安装wget
yum install wget
下载
sudo wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
解压
sudo tar xvf apache-maven-3.5.0-bin.tar.gz
添加环境变量
sudo vi /etc/profile
在profile文件中加入如下内容
export M2_HOME=/opt/apache-maven-3.5.0
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
如果需要特别设置内存的话,可以加上这句
export MAVEN_OPTS="-Xms256m -Xmx512m"
保存,使profile生效
source /etc/profile
查看版本
mvn -version
设置本地仓库
MAVEN目录下的conf下的settings.xml文件是Maven的配置文件
新建一个repo文件夹,作为仓库的文件夹
cd /opt/apache-maven-3.5.0/
mkdir repo
编辑settings.xml
cd /opt/apache-maven-3.5.0/conf/
vi settings.xml
修改这一行的本地仓库,指向/opt/apache-maven-3.5.0/repo/
<localRepository>/opt/apache-maven-3.5.0/repo/</localRepository>
添加阿里云的镜像
在<mirrors></mirros>中添加阿里云的镜像
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>