maven,jcenter下载不了?国内镜像解决

导入新的工程时经常需要下载好多库,有些库因为种种原因无法下载下来。这时候,可以有以下的解决方案。

解决方法一:

https:改成 http协议下载

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
//        jcenter()
        jcenter(){url 'http://jcenter.bintray.com/'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
//        jcenter()
        jcenter(){url 'http://jcenter.bintray.com/'}
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

方法二:
切换到国内的Maven镜像仓库。
修改项目根目录下 build.gradle 文件,将 jcenter() 或者 mavenCentral() 替换掉即可。
修改成这样

buildscript{
    repositories{
        maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
        google()
}
    dependencies{
        classpath'com.android.tools.build:gradle:3.1.4'
        // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
    }
}
allprojects{
    repositories{
        maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

然后,重新同步一下就可以很快下载了

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Maven 镜像仓库是用于存储和获取 Maven 项目所需的依赖项的地方。以下是一些好用的 Maven 镜像仓库地址: 1. Central Repository(中央仓库):https://repo.maven.apache.org/maven2/ Central Repository 是 Maven 默认的镜像仓库,含了大量的开源 Java 项目和库。它是最权威和最全面的 Maven 镜像仓库之一。 2. Aliyun Maven(阿里云仓库):https://maven.aliyun.com/repository/ Aliyun Maven 是阿里云提供的稳定和高速的 Maven 镜像仓库。它提供了国内访问速度比较快的镜像地址,对于国内开发者来说非常方便。 3. JCenter(JFrog Bintray):https://jcenter.bintray.com/ JCenter 是一个广受欢迎的 Maven 镜像仓库,含了大量的 Java 项目和库。它的稳定性和可靠性得到了开发者的认可。 4. Spring Repository(Spring仓库):https://repo.spring.io/release/ Spring Repository 是 Spring 官方提供的 Maven 镜像仓库,用于存储 Spring 相关的项目和库。对于使用 Spring 框架的开发者来说,Spring Repository 是一个重要的资源来源。 5. Maven 中国镜像:https://maven.aliyun.com/nexus/content/groups/public/ Maven 中国镜像是由阿里云维护的一个 Maven 镜像仓库,它含了来自 Central Repository 的所有项目,同时提供了一些其他常用的第三方库。 以上列举的几个 Maven 镜像仓库都经过了广泛的使用和验证,拥有良好的稳定性和可靠性。根据个人的需求和网络环境,可以选择合适的镜像仓库加速 Maven 项目的构建和依赖下载
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值