maven 配置: 修改默認的 .m2倉庫 默認存儲路徑.


maven 配置: 修改默認的 .m2倉庫 默認存儲路徑.

一 、在系統maven里修改

1.在maven_HOME/conf/下找到配置文檔 settings.xml

在文檔中添加如下的配置說明

  <localRepository>/home/morpheus/.m2/repository</localRepository>
  • 1

例如 
settings.xml :

....
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <!-- 2017-1-9 morpheus 修改默認.m2 路徑--> <localRepository>/home/morpheus/.m2/repository</localRepository> <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> --> ....
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

二、修改IDE中的maven默認 .m2 路徑

在IDE中的maven配置 其實也依賴於settings.xml文檔 
同 (一) 理,修改配置文檔中默認的存儲路徑即可:

1.Netbeans 中的maven配置文檔路徑如下 
/usr/local/netbeans-8.2/java/maven/conf

2.Eclipse 中的maven配置 需要這樣做: 
[Windows] -> [perferences] -> [Maven] -> [User Settings] -> [User Settings
將其中的配置文件路徑 改為你的配置文件路徑。 
例如: 
這里寫圖片描述

Eclipse 會自動讀取其中的默認路徑。 
*備注:Local Repostory 路徑是不可以自己修改的。只能從settings.xml中讀取。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM