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中讀取。