美文网首页
记录一次使用allowInsecureProtocol 属性解决

记录一次使用allowInsecureProtocol 属性解决

作者: 刺猬Hedgehog | 来源:发表于2021-07-27 19:18 被阅读0次

背景:

Gradle升级到7.1后,在IDEA中编译工程编译不通过,提示如下:


image.png

解决办法:

通过点击错误里的链接发现,配置了除 maven 中央仓库之外的其他不安全的仓库(至于“不安全”在这里的定义,我也不是很清楚,一些国内的镜像仓库例如阿里的也是“不安全”的)
gradle 中有一个属性可以允许 gradle 使用“不安全”的仓库并且不报警告信息
该属性是 allowInsecureProtocol,官方解释如下:

image.png

翻译过来就是 指定通过不安全的HTTP连接与仓库通信是否可接受,如果该属性的值设置为 true,则表示接受“不安全”的仓库地址。
在build.gradle中进行如下配置即可:

repositories {
    ...
        
    maven {
        allowInsecureProtocol = true
        ...
    }
}

参考:
https://docs.gradle.org/7.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository
https://blog.csdn.net/qi_ming_hao_nan/article/details/114799678

相关文章

网友评论

      本文标题:记录一次使用allowInsecureProtocol 属性解决

      本文链接:https://www.haomeiwen.com/subject/knwomltx.html