本文主要是介绍ubuntu22.04 arrch64版在线安装maven,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
脚本
if type -p mvn; thenecho "maven has been installed."elsecd /home/zenglgwget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz --no-check-certificatetar vxf apache-maven-3.9.5-bin.tar.gz rm -rf /usr/local/maven3mv apache-maven-3.9.5 /usr/local/maven3#设置mvn的环境变量checkMvnExist(){mvn1=$(grep -n "MAVEN_HOME=.*" /etc/profile | cut -f1 -d':')if [ -n "$mvn1" ];thensed -i "${mvn1}d" /etc/profilefimvn2=$(grep -n "export MAVEN_HOME" /etc/profile | cut -f1 -d':')if [ -n "$mvn2" ];thensed -i "${mvn2}d" /etc/profilefimvn3=$(grep -n "export PATH=${PATH}:${MAVEN_HOME}/bin" /etc/profile | cut -f1 -d':')if [ -n "$mvn3" ];thensed -i "${mvn3}d" /etc/profilefi}checkMvnExistecho "MAVEN_HOME=/usr/local/maven3" >> /etc/profilesource /etc/profileecho "export MAVEN_HOME" >> /etc/profileif [[ ${PATH} =~ ${MAVEN_HOME}/bin ]]; thenecho " MAVEN_HOME has been set"elseecho "export PATH=${PATH}:${MAVEN_HOME}/bin" >> /etc/profileecho "setting MAVEN_HOME path successful."fi#保存刷新source /etc/profilefi
mvn -v
安装成功
这篇关于ubuntu22.04 arrch64版在线安装maven的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!