gradle构建报错(Using insecure protocols with repositories, without explicit opt-in, is unsupported.)

        在执行一个gradle构建任务时,报如下错        

> Task :extractIncludeProto FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':extractIncludeProto'.
> Could not resolve all dependencies for configuration ':compileProtoPath'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported.

* Try:
> Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
> For more information, please refer to https://docs.gradle.org/8.3/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol in the Gradle documentation.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 676ms
1 actionable task: 1 executed

        根据提示可知,是配置的仓库使用了不安全的http协议,需要更改下Maven仓库配置。但为什么会使用到Maven仓库,我找到项目下的build.gradle文件,发现有这么一段配置。

repositories {
    maven { // The google mirror is less flaky than mavenCentral()
        url "https://maven-central.storage-download.googleapis.com/maven2/" }
    mavenCentral()
    mavenLocal()
}

        其中mavenCentral()、mavenLocal()就是设置了maven仓库。

        在mac os下,找到家目录下的 ~/.gradle/init.gradle文件,原内容为

allprojects {
    repositories {
        maven {
            url "http://maven.aliyun.com/nexus/content/groups/public"
        }
    }
}

        修改文件中的内容为https,即为

allprojects {
    repositories {
        maven {
            url "https://maven.aliyun.com/nexus/content/groups/public"
        }
    }
}

         保存后再运行构建任务就成功了,以此记录一下!

        当然也可以修改项目下的build.gradle文件,在仓库配置中加入allowInsecureProtocol = true

repositories {
    // maven { // The google mirror is less flaky than mavenCentral()
    //    url "https://maven-central.storage-download.googleapis.com/maven2/" }
    // mavenCentral()
    // mavenLocal()

    maven {
        allowInsecureProtocol = true
        url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值