Maven之阿里雲鏡像倉庫配置


阿里雲倉庫地址:

https://maven.aliyun.com/mvn/guide

進入詳細看配置

start.spring.io 直接用 https://start.aliyun.com 替代

central倉和jcenter倉的聚合倉:

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

spring:

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

spring-plugin:

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

public:

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

1. 全局配置

添加阿里雲的鏡像到maven的setting.xml配置中,這樣就不需要每次在pom中,添加鏡像倉庫的配置,在mirrors節點下面添加子節點:

<mirror>  
      <id>alimaven</id>  
      <name>aliyun maven</name>  
      <url>https://maven.aliyun.com/repository/public/</url>  
      <mirrorOf>central</mirrorOf>          
    </mirror>
    <mirror>
      <id>repo2</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://repo2.maven.org/maven2/</url>
    </mirror>
    <mirror>
      <id>ui</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://uk.maven.org/maven2/</url>
    </mirror>

 

注:< mirrorOf>可以設置為哪個中央倉庫做鏡像,為名為“central”的中央倉庫做鏡像,寫作< mirrorOf>central< /mirrorOf>;為所有中央倉庫做鏡像,寫作< mirrorOf>< /mirrorOf>。Maven默認中央倉庫的id 為 central。id是唯一的。
重要:除非你有把握,否則不建議使用< mirrorOf>
< /mirrorOf>的方式。

2. 單項目配置

單項目配置時,需要修改pom.xml文件。pom.xml文件中,沒有mirror元素。在pom.xml文件中,通過覆蓋默認的中央倉庫的配置,實現中央倉庫地址的變更。

  <repositories>
        <repository>
            <id>central</id>
            <name>aliyun maven</name>
            <url>https://maven.aliyun.com/repository/public/</url>
            <layout>default</layout>
            <!-- 是否開啟發布版構件下載 -->
            <releases>
                <enabled>true</enabled>
            </releases>
            <!-- 是否開啟快照版構件下載 -->
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

 

注:Maven默認中央倉庫的id 為 central。id是唯一的。因此使用< id>central< /id>覆蓋了默認的中央倉庫。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM