Maven官網http://maven.apache.org/download.cgi
想獲得最新版請點選Maven官網檢視,可以尋得清華鏡像下的 maven tar包
http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/
注意:前提是安裝了JDK,若非,請參考我的這篇部落格
1、擷取安裝包并解壓
# cd /usr/local
# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
# tar -zxvf apache-maven-3.6.1-bin.tar.gz
2、配置環境變量,添加export
# vim /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.1
export PATH=${MAVEN_HOME}/bin:${PATH}
# source /etc/profile
# mvn -v
3、添加阿裡雲鏡像
# vim $MAVEN_HOME/conf/settings.xml
或者
# cp $MAVEN_HOME/conf/settings.xml ~/.m2/settings.xml
# vim ~/.m2/settings.xml
添加以下鏡像配置
<mirrors>
<!-- 當 nexus-aliyun 下不了的包,或許這個鏡像能下,
才開放它,這個實在太慢,而且要把它放在首位,即 nexus-aliyun 之前,做過測試。
是以它的用途隻有那麼一瞬間,就是或許它能下載下傳,可以通過 url 去查找确定一下
-->
<!-- <mirror>
<id>spring-libs-milestone</id>
<mirrorOf>central</mirrorOf>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone</url>
</mirror> -->
<!-- nexus-aliyun 首選,放第一位,有不能下載下傳的包,再去做其他鏡像的選擇 -->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<!-- 備選鏡像,也是可以通過 url 去查找确定一下,
該鏡像是否含有你想要的包,它比 spring-libs-milestone 快 -->
<mirror>
<id>central-repository</id>
<mirrorOf>*</mirrorOf>
<name>Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</mirror>
</mirrors>