1.下載Maven装诡,解壓縮
macdeMacBook-Pro:apache-maven-3.5.2 mac$ pwd
/Users/mac/dev/apache-maven-3.5.2
2.設置環(huán)境變量
- 編輯文件
vi ~/.bash_profile
- 修改內容
M3_HOME=/Users/mac/dev/apache-maven-3.5.2
PATH=$M3_HOME/bin:$PATH
export M3_HOME
export PATH
- 立即生效
source ~/.bash_profile
- 驗證結果
macdeMacBook-Pro:apache-maven-3.5.2 mac$ mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T00:58:13-07:00)
Maven home: /Users/mac/dev/apache-maven-3.5.2
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
3.設置本地倉庫
- 編輯文件
/Users/mac/dev/apache-maven-3.5.2/conf/settings.xml
- 編輯內容
<settings>
<localRepository>/Users/mac/dev/mavenlib</localRepository>
</settings>
4.設置國內鏡像庫
- 編輯文件
/Users/mac/dev/apache-maven-3.5.2/conf/settings.xml
- 編輯內容
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
Maven查找順序,先找本地 再找國內鏡像 再找中央倉庫 把快的放在前面颗祝。