Maven配置遠程倉庫

方法一:修改maven配置文件

我使用的是IDEA編譯器,使用maven自己的庫下載文件非常的慢。阿里代理了很多公共的maven倉庫,使用maven.aliyun.com中的倉庫地址作爲下載源,速度更快更穩定。

打開你的maven的安裝地址,找到conf文件夾下面的settings.xml文件並打開,在<mirrors></mirrors>標籤中間插入鏡像的配置參數。

<mirror>
    <id>aliyunmaven</id>
    <mirrorOf>central</mirrorOf>
    <name>central庫</name>
    <url>https://maven.aliyun.com/repository/central</url>
</mirror>

如果需要替換的話,將URL中的地址替換爲下表中的Path列所對應的url。

Repository

Type

Policy

Path

apache snapshots

proxy

SNAPSHOT

https://maven.aliyun.com/repository/apache-snapshots

central

proxy

RELEASE

https://maven.aliyun.com/repository/central

google

proxy

RELEASE

https://maven.aliyun.com/repository/google

gradle-plugin

proxy

RELEASE

https://maven.aliyun.com/repository/gradle-plugin

jcenter

proxy

RELEASE

https://maven.aliyun.com/repository/jcenter

spring

proxy

RELEASE

https://maven.aliyun.com/repository/spring

spring-plugin

proxy

RELEASE

https://maven.aliyun.com/repository/spring-plugin

public

group

RELEASE

https://maven.aliyun.com/repository/public

releases

hosted

RELEASE

https://maven.aliyun.com/repository/releases

snapshots

hosted

SNAPSHOT

https://maven.aliyun.com/repository/snapshots

grails-core

proxy

RELEASE

https://maven.aliyun.com/repository/grails-core

mapr-public

proxy

RELEASE

https://maven.aliyun.com/repository/mapr-public

保存並重啓編譯器即可。

方法二:修改項目的pom.xml文件

打開你的項目,找到pom.xml文件,在<repositories></repositories>中添加<repository></repository>倉庫,格式如下。倉庫的地址同第一種方法中的倉庫地址。

<repositories>
        <repository>
            <id>maven-ali</id>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </repository>
</repositories>

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章