環境版本:
Mac OS: 10.13.4
JDK: 1.8
Idea: 2018.3
Maven: 3.6.0
Maven 相關配置:
Maven 下載:
名詞解釋:
Binary: 通過編譯工具編譯后的軟件版本。
Source: 沒有編譯的源碼軟件版本。
tar.gz: 壓縮文件格式,一般為Linux平台。
zip: 壓縮文件格式,一般為Windows平台。
安裝配置:
1、將解壓下載好的文件copy一份到系統資源庫:
備注:根據實際情況填寫。
參考:/Library/apache-maven
2、配置環境變量:
命令窗口執行命令:vi ~/.bash_profile
進入編輯模式下,輸入鍵盤I鍵。
填寫一下內容:
export M2_HOME=/library/apache-maven
export PATH=$PATH:$M2_HOME/bin
保存文件並退出,輸入鍵盤 shift+: ,並輸入!qw 回車。
備注:M2_HOME配置為maven解壓后的包路徑,請根據實際情況配置。
3、生效.base_profile文件。
輸入一下命令:
source ~/.bash_profile
4、測試Maven是否安裝完成。
輸入一下命令:
mvn -v
參考:
idea 相關配置:
配置Maven的setting.xml文件。
參考路徑:
/Library/apache-maven/config/settting.xml
配置maven的settings.xml文件,添加如下配置(替換系統默認下載jar的服務器為阿里雲,加快jar包下載速度):
<mirrors> <mirror> <id>ali maven</id> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
備注:</mirrors> 標簽根據實際情況添加。
附加:
<mirrors> <mirror> <id>ali maven</id> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>ui</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://uk.maven.org/maven2/</url> </mirror> <mirror> <id>ibiblio</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url> </mirror> <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> </mirror> <!--訪問慢的網址放入到后面--> <mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>net-cn</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://maven.net.cn/content/groups/public/</url> </mirror> <mirror> <id>JBossJBPM</id> <mirrorOf>central</mirrorOf> <name>JBossJBPM Repository</name> <url>https://repository.jboss.org/nexus/content/repositories/releases/</url> </mirror> </mirrors>
idea工具配置maven:
plugin update policy: check for updates 。
pom.xml內容變動就更新。
Maven home directory:
maven的解壓包存放路徑。
User settings file:
maven setttings.xml 配置文件路徑,項目默認讀取該maven的配置參數。