gradle - Gradle 允许不安全的存储库镜像
问题描述
我正在开始一个新项目。我不需要任何本地依赖项。但是在我们的组织中,我们使用在 http 上运行的本地 maven 镜像。使用 Maven settings.xml
<mirrors>
<mirror>
<id>nexus-local</id>
<mirrorOf>external:*</mirrorOf>
<url>http://nexus-local.org.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
我尝试在 gradle 中配置不安全的连接以使其满意,例如
- 构建.gradle
repositories {
maven {
url "http://nexus-local.org.com/nexus/content/groups/public"
allowInsecureProtocol = true
}
}
- 构建.gradle.kts
repositories {
maven {
url = uri("http://nexus-local.org.com/nexus/content/groups/public")
isAllowInsecureProtocol = true
}
}
但是在这两种情况下,当我运行 gradle 时,它都会因错误而崩溃(因此结果与没有此配置的结果相同):
* What went wrong:
A problem occurred configuring root project 'panic'.
> Could not resolve all dependencies for configuration ':classpath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://nexus-local.org.com/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
我究竟做错了什么?
解决方案
刚刚在我的组织中遇到了这个问题。通过在 ~/.gradle/init.gradle 中添加以下内容来解决它
allprojects {
repositories {
maven {
url "http://artifactory.myorg.org/repo/"
allowInsecureProtocol true
}
mavenLocal()
}
}
希望这有效。
推荐阅读
- r - 按日期 r 对列的子集进行排序
- macos - Specflow 3.1 + .NET core Visual Studio mac 不显示功能文件也不理解小黄瓜
- python - 通过 apiv4 python 将值插入谷歌表格
- reactjs - 如何使用reactjs获取json文件中的最后一行
- python - 循环遍历具有自定义类的多个值的字典?
- amazon-web-services - AWS Elasticbeanstalk CLI 忽略实例类型选项
- python - 在 django 中找不到模板 url
- javascript - 使用简单的 JavaScript 函数隐藏 div 元素的问题
- python - 列出当前登录用户的对象
- docker - 在 docker-selenium 中测试可以在本地运行但不能在 Jenkins 上下载文件