版權聲明:本文為博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
</div>
<!--一個博主專欄付費入口-->
<!--一個博主專欄付費入口結束-->
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-833878f763.css">
<div id="content_views" class="markdown_views prism-atom-one-dark">
<!-- flowchart 箭頭圖標 勿刪 -->
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
</svg>
<p>在使用 Nexus 搭建自己的 Maven 倉庫時,我們需要為一些公共的 Maven 倉庫做鏡像,這就需要這些倉庫的真實地址了,下面是這些倉庫的地址:</p>
倉庫名稱 | 倉庫地址 | gradle 引用方式 |
---|---|---|
jcenter | https://jcenter.bintray.com | jcenter() |
mavenCentral | https://repo1.maven.org/maven2 或 http://central.maven.org/maven2/ (比較慢) | mavenCentral() |
https://dl.google.com/dl/android/maven2/ | google() | |
阿里雲 | http://maven.aliyun.com/nexus/content/repositories/jcenter/ 或 http://maven.aliyun.com/nexus/content/groups/public/ | maven {url ‘阿里地址’} |
注:
1. mavenCentral 官網地址 http://mvnrepository.com/ 在這里可以根據名稱搜索相應的庫和查看熱門的庫。
2. google 的 maven 倉庫是不支持瀏覽的,如果你需要下載特定一個庫,可以自行拼接這樣的地址 https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.0.1/compiler-3.0.1-sources.jar 來進行下載,其它 maven 倉庫同理。
3. 當我們通過 gradle 下載過第三方庫時,可以在 gradle 的緩存目錄 找到它們,
windows: C:\Users\用戶名\.gradle\caches\modules-2\files-2.1
OSX: /Users/用戶名/.gradle/caches/modules-2/files-2.1
如果你使用了 Android Studio 自帶的 gradle 那么,xxx\android-studio\gradle\gradle-版本號\caches\modules-2\files-2.1 下也有大量庫文件。
4. 由於國內網絡環境的原因,我們可以通過下面方法選擇最優 Maven 倉庫:
repositories {
// maven庫
def aliMaven = "http://maven.aliyun.com/nexus/content/groups/public/"
def cMaven = "https://repo1.maven.org/maven2"
// 先從url中下載jar若沒有找到,則在artifactUrls中尋找
maven {
url aliMaven
artifactUrls cMaven
}
}
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
原文地址:https://blog.csdn.net/niuzhucedenglu/article/details/80406099