原文地址:http://blog.csdn.net/wanghantong/article/details/36427433
1、默认路径:maven本地仓库的默认位置:无论是Windows还是Linux,在用户的目录下都有一个.m2/repository/的仓库目录,这就是Maven仓库的默认位置。
2、更改路径:先在/.m2/目录下创建settings.xml文件,然后在~/.m2/settings.xml,设置localRepository元素的值为想要的仓库地址,如下
<settings>
<localRepository>D:\maven_space</localRepository>
</settings>
完整settings.xml内如如下
<?xml version="1.0" encoding="UTF-8"?>
<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>D:\maven_space</localRepository>
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
</settings>
全局修改:
1.2 更改配置全局范围的本地仓库:在M2_HOME/conf/settings.xml中更改配置,更改配置的方法同上
注意:此时更改后,所有的用户都会受到影响,而且如果maven进行升级,那么所有的配置都会被清除,所以要提前复制和备份M2_HOME/conf/settings.xml文件
因此一般情况下不推荐配置全局的settings.xml