Mac 安裝 maven和配置
阿新 • • 發佈:2018-12-12
- 解壓下載的二進位制包
- 編輯配置檔案
vim ~/.bashrc
新增如下配置
export M2_HOME=/Users/xxxx/development/apache-maven-3.5.4 #maven 二級制包解壓之後存放的位置
export PATH=$PATH:$M2_HOME/bin
-
及時生效
source ~/.bashrc
-
驗證
mvn -v
輸出如下提示,說明成功
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00) Maven home: /Users/xxxx/development/apache-maven-3.5.4 Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"
- 修改setting.xml 為了提高第三方庫的下載速度,我需要修改setting.xml。修改預設的遠端倉庫的地址,換成阿里雲提供的遠端倉庫地址,具體操作如下所示:
在maven的解壓目錄中,即/Users/xxxx/development/apache-maven-3.5.4
中找到conf/settings.xml
檔案,在<mirrors>
中新增如下內容。
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name> Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
整個<mirrors>
節點如下 所示:
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<!-- 這是新增加的內容-->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>