我正在开始一个新项目。为此我不需要任何本地依赖项。但在我们的组织中,我们使用在 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
}
}
- build.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()
}
}
希望这能起作用。
关于Gradle 允许不安全的存储库镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69135147/