Gradle构建项目时报错
Download https://services.gradle.org/distributions/gradle-7.2-bin.zip, took 16 s 48 ms (114.35 MB)
Starting Gradle Daemon...
Gradle Daemon started in 2 s 321 ms
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'projectName'.
> Could not resolve all dependencies for configuration ':classpath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.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 7+ 版本中的不安全 HTTP 连接,我们需要将布尔值allowInsecureProtocol指定为 true 以MavenArtifactRepository
关闭。
由于您已收到此存储库错误sonatype
,因此您需要按如下方式设置存储库:
- Groovy DSL
repositories {
maven {
url "http://oss.sonatype.org/content/repositories/snapshots"
allowInsecureProtocol = true
}
// other repositories ...
}
- Kotlin DSL
repositories {
maven {
url = uri("http://oss.sonatype.org/content/repositories/snapshots")
isAllowInsecureProtocol = true
}
// other repositories ...
}
参与讨论