常用Maven庫,映象庫及maven/gradle配置(小結)
阿新 • • 發佈:2020-12-04
平時用到的庫
倉庫名 | 地址 | 備註 |
---|---|---|
mavenCentral | https://repo1.maven.org/maven2/ https://repo.maven.apache.org/maven2/ |
全區最大的maven庫,第二個為apache的映象庫,gradle預設地址 |
jcenter | https://jcenter.bintray.com/anverus/tools/ | bintray私有庫 相容mavenCentral中心倉庫,且效能更優 |
https://dl.google.com/dl/android/maven2/ | google私有庫 | |
jitpack | https://www.jitpack.io | 自動構建庫github,及其他git 專案,自帶cdn加速 |
mavenLocal | ~/.m2/repository | 本地倉庫 |
Spring | https://repo.spring.io/libs-milestone//anverus/tools/ | Java Spring庫,包含於jcenter/mavenCentral |
Spring Plugins | https://repo.spring.io/plugins-release/ | Java Spring 外掛庫,包含於jcenter/mavenCentral |
國內阿里雲映象庫
倉庫名稱 | 代理源地址 | 使用地址 |
---|---|---|
central | https://repo1.maven.org/maven2/ | https://maven.aliyun.com/repository/central |
jcenter | http://jcenter.bintray.com/ | https://maven.aliyun.com/repository/jcenter |
public | central/jcenter 聚合倉 | https://maven.aliyun.com/repository/public |
https://maven.google.com/ | https://maven.aliyun.com/repository/google | |
gradle-plugin | https://plugins.gradle.org/m2/ | https://maven.aliyun.com/repository/gradle-plugin |
spring | http://repo.spring.io/libs-milestone/ | https://maven.aliyun.com/repository/spring |
spring-plugin | http://repo.spring.io/plugins-release/ | https://maven.aliyun.com/repository/spring-plugin |
加速配置
將central/jcenter/google 換成阿里雲地址即可
maven配置
開啟maven的配置檔案(windows機器一般在maven安裝目錄的conf/settings.xml),在<mirrors></mirrors>標籤新增mirror子節點:
<mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里雲公共倉庫</name> <url>https://maven.aliyun.com/repository/public</url> </mirror>
如果想使用其它代理倉庫,可在<repositories></repositories>節點中加入對應的倉庫使用地址。以使用google代理倉為例:
<repository> <id>spring</id> <url>https://maven.aliyun.com/repository/google</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository>
gradle配置
在build.gradle檔案中加入以下程式碼:
allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/google/' } // 阿里的同步實時性較差,如果想要使用最新版本的,建議再加上 google() google() mavenLocal() } }
參考
maven repo排名
阿里雲效文件
阿里雲repositories 一覽
到此這篇關於常用Maven庫,映象庫及maven/gradle配置(小結)的文章就介紹到這了,更多相關Maven庫,映象庫內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!