常用 Maven 仓库地址

本文提供了Maven仓库的详细配置信息,包括jcenter、mavenCentral等常用仓库的地址及引用方式。同时介绍了如何选择最优Maven仓库的方法,并提供了一些实用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在使用 Nexus 搭建自己的 Maven 仓库时,我们需要为一些公共的 Maven 仓库做镜像,这就需要这些仓库的真实地址了,下面是这些仓库的地址:

仓库名称仓库地址gradle 引用方式
jcenterhttps://jcenter.bintray.comjcenter()
mavenCentralhttps://repo1.maven.org/maven2http://central.maven.org/maven2/ (比较慢)mavenCentral()
googlehttps://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
        }
    }
### Maven 常用仓库地址 Maven 构建工具依赖于中央仓库来获取所需的库和插件。除了官方的中央仓库外,还有其他常用的公共镜像站点可供选择。 #### 中央仓库 这是默认配置下 Maven 使用的主要仓库,包含了大量开源项目的构件。 - URL: `https://repo.maven.apache.org/maven2`[^1] #### 公共镜像站 为了提高下载速度并减少网络延迟的影响,可以选择一些知名的公共镜像站作为替代源: - **Maven Repository** - 浏览器访问网址:[Search/Browse/Explore (mvnrepository.com)](https://mvnrepository.com/) - 配置URL: `https://repo1.maven.org/maven2/` - **阿里云 Maven 镜像** - 提供稳定快速的服务给国内开发者 - URL: `http://maven.aliyun.com/nexus/content/groups/public/` - **网易 Maven 镜像** - 另一选项对于中国地区的用户来说也是不错的选择之一 - URL: `http://mirrors.163.com/maven/repository/maven-central/` 这些镜像站点能够有效提升构建过程中的资源加载效率,特别是在跨国境的数据传输场景下表现尤为明显。 ```xml <repositories> <!-- 官方中央仓库 --> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> <!-- Maven Repository --> <repository> <id>maven-repo</id> <url>https://repo1.maven.org/maven2/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> <!-- 阿里云 Maven 镜像 --> <repository> <id>aliyun-maven</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> <!-- 网易 Maven 镜像 --> <repository> <id>netease-maven</id> <url>http://mirrors.163.com/maven/repository/maven-central/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值