1. 程式人生 > >修改Maven倉庫地址

修改Maven倉庫地址

maven https ret false this Language ring read onf

%USERPROFILE%\.m2\settings.xml例如:C:\Users\LongShu\.m2\settings.xml
可以自定義Maven的一些參數,
復制%M2_HOME%\conf\settings.xml到這個目錄修改一下配置。

  1. 本地倉庫
    在settings節點裏添加
<localRepository>D:\Dev_Tool\m2repository</localRepository>

本地倉庫地址將從%USERPROFILE%\.m2\變為D:\Dev_Tool\m2repository\

  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>

修改Maven倉庫地址