Gradle常见问题解决

Could not get resource ‘https://jcenter.bintray.com’

在看Netflix conductor源码时遇到的一个问题,记录一下。
由于conductor不是使用常规的maven,而是使用Gradle作为编译工具,并且其jar包仓库是jcenter,不是nexus或者mvnrepository。故而在编译项目时遇到这个报错(Stack Trace适当简略):

Could not download commons-compress.jar (org.apache.commons:commons-compress:1.16)
      > Could not get resource 'https://jcenter.bintray.com/org/apache/commons/commons-compress/1.16/commons-compress-1.16.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/commons-compress-1.16.jar'.

参考
找到项目的build.gradle文件的节点*.repositories

buildscript {
	repositories {
		// 注释,并添加下面一行
        // jcenter()
        maven { url "http://jcenter.bintray.com" }        
    }
}
allprojects {
    repositories {
    	// 默认的jcenter是https协议的,也就是说把https换成http,遇到其他类似的问题,都可以这般尝试
		// jcenter()
        maven { url "http://jcenter.bintray.com" }
    }
}

但是gradle-wrapper.properties文件不能修改为httpshttp
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

Could not get resource ‘https://plugins.gradle.org/m2’

下载插件失败:

org.gradle.api.resources.ResourceException: Could not get resource 'https://plugins.gradle.org/m2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar'.
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/maven-ant-tasks-2.1.3.jar
Caused by: java.net.SocketException: Software caused connection abort: recv failed

解决方法参考
settings.gradle文件最顶部添加如下配置:

pluginManagement {
    repositories {
        maven {
            url 'http://maven.aliyun.com/repository/gradle-plugin'
        }
        gradlePluginPortal()
    }
}
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

johnny233

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值