修改Maven仓库地址

%USERPROFILE%.m2settings.xml例如:C:UsersLongShu.m2settings.xml 
可以自定义Maven的一些参数, 
复制%M2_HOME%confsettings.xml到这个目录修改一下配置。

  1. 本地仓库 
    在settings节点里添加
<localRepository>D:Dev_Toolm2repository</localRepository>

本地仓库地址将从%USERPROFILE%.m2变为D:Dev_Toolm2repository

  1. 远程仓库 
    在mirrors节点内添加
<mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<mirror>
    <id>jcenter</id>
    <mirrorOf>central</mirrorOf>
    <name>jcenter.bintray.com</name>
    <url>http://jcenter.bintray.com/</url>
</mirror>

<mirror>
    <id>repo1</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://repo1.maven.org/maven2/</url>
</mirror>
<mirror>
    <id>repo2</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://repo2.maven.org/maven2/</url>
</mirror>

将把原来https的仓库变为http的aliyun中央仓库。

  1. 修改项目仓库 
    在项目pom.xml的project节点内添加以下内容即可
<repositories>
    <repository>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </repository>
    <repository>
        <id>jcenter</id>
        <name>jcenter Repository</name>
        <url>http://jcenter.bintray.com/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
原文地址:https://www.cnblogs.com/ThinkVenus/p/7219951.html