maven 配置: 修改默认的 .m2仓库 默认存储路径.

一 、在系统maven里修改

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

在文档中添加如下的配置说明

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

例如
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>
  -->
  ....

二、修改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中读取。

猜你喜欢

转载自blog.csdn.net/timo1160139211/article/details/54289938
今日推荐