安裝
注意:安裝前務(wù)必先安裝好JDK(Java環(huán)境)
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.配置環(huán)境變量?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.指定遠(yuǎn)程倉庫目錄锐峭,這里以 阿里云 為例
<mirror>
? ? ? ? ? ? ? ? <id>nexus-aliyun</id>
? ? ? ? ? ? ? ? <mirrorOf>central</mirrorOf>
? ? ? ? ? ? ? ? <name>Nexus aliyun</name>
? ? ? ? ? ? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
驗(yàn)證
1.使用 mvn -v 命令驗(yàn)證是否成功安裝际邻,成功安裝后如下圖所示