一键安装Maven脚本
#!/bin/bash
if [ -z “${MAVEN_HOME}” ]; then
#得到时间
TIME_FLAG=`date +%Y%m%d_%H%M%S`
#备份配置文件
cp /etc/profile /etc/profile.bak_$TIME_FLAG
echo “Begin to install maven,Please waiting…”
#解压maven
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
tar -xzvf apache-maven-3.0.5-bin.tar.gz
#拷贝maven到安装目录
cp -rf apache-maven-3.0.5 /usr/local/
echo “######################################”
echo “Begin to config environment variables,please waiting…”
echo “######################################”
#修改maven的环境变量,直接写入配置文件
echo “MAVEN_HOME=/usr/local/apache-maven-3.0.5” >>/etc/profile
echo “PATH=\$PATH:\$MAVEN_HOME/bin” >>/etc/profile
#运行后直接生效
source /etc/profile
echo “环境变量设置成功”
else
echo “本机已安装maven无需再次安装”
fi
maven仓库阿里镜像设置
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
https://help.aliyun.com/document_detail/102512.html?spm=a2c40.aliyun_maven_repo.0.0.36183054eGk3vS