You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Gradle发布时「远程仓库不支持SHA-256/512」报错

解决Gradle发布到Nexus时的校验码上传警告

问题场景

使用IntelliJ IDEA构建Spring Boot项目,基于Gradle 7.5 + Kotlin 1.6.21,通过maven-publish插件发布jar到私有Nexus仓库时,控制台出现以下警告:

Cannot upload checksum for snapshot-maven-metadata.xml because the remote repository doesn't support SHA-256. This will not fail the build.
Cannot upload checksum for snapshot-maven-metadata.xml because the remote repository doesn't support SHA-512. This will not fail the build.
Cannot upload checksum for module-maven-metadata.xml because the remote repository doesn't support SHA-256. This will not fail the build.
Cannot upload checksum for module-maven-metadata.xml because the remote repository doesn't support SHA-512. This will not fail the build.

已知建议在gradle.properties中设置systemProp.org.gradle.internal.publish.checksums.insecure=true,但项目使用Gradle Wrapper,找不到该文件,以下是可行解决方法:

解决方法

方法1:手动创建项目级gradle.properties

直接在项目根目录新建gradle.properties文件,添加配置:

systemProp.org.gradle.internal.publish.checksums.insecure=true

Gradle会自动识别这个文件,即使使用Wrapper也生效。

方法2:命令行参数传递

执行发布命令时,直接通过命令行指定系统属性:

./gradlew publish -Dorg.gradle.internal.publish.checksums.insecure=true

Windows环境使用:

gradlew.bat publish -Dorg.gradle.internal.publish.checksums.insecure=true

方法3:在构建脚本中配置系统属性

在项目的build.gradle.kts(Kotlin脚本)中添加以下代码,在构建初始化时设置系统属性:

gradle.startParameter.systemProperties["org.gradle.internal.publish.checksums.insecure"] = "true"

方法4:配置全局gradle.properties

如果希望该配置对所有本地Gradle项目生效,可以在用户目录下创建全局的gradle.properties:

  • Windows:C:\Users\<你的用户名>\.gradle\gradle.properties
  • Linux/macOS:~/.gradle/gradle.properties
    添加同样的配置项即可。

内容的提问来源于stack exchange,提问作者looko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 19:00:59