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

Gradle项目构建报错groovy-datetime版本不匹配问题求助

Groovy版本冲突修复方案

核心冲突原因

你当前的Spock组件适配的Groovy版本不统一:

  • spock-core:1.3-groovy-2.5 依赖Groovy 2.5.x版本
  • spock-spring:2.0-M3-groovy-3.0 依赖Groovy 3.0.x版本

两者拉取的Groovy子包版本不一致,直接导致了模块版本冲突报错。你之前尝试的排除Groovy依赖的方案无效,是因为没有解决Spock组件本身适配版本不匹配的核心问题。

修复方案

你可以选择以下任意一种方案统一版本,推荐优先使用方案一,兼容性更强。

方案一:统一使用Groovy 2.5.x版本

修改test依赖配置,将spock-spring替换为适配Groovy 2.5的版本:

testImplementation 'org.codehaus.groovy:groovy-all:2.5.10'
testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'
// 替换原来的2.0-M3-groovy-3.0版本,和spock-core保持适配版本一致
testImplementation 'org.spockframework:spock-spring:1.3-groovy-2.5'

如果修改后仍有冲突,在build.gradle中添加全局版本锁定配置:

configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'org.codehaus.groovy') {
            details.useVersion '2.5.10'
        }
    }
}

方案二:统一使用Groovy 3.0.x版本

升级Groovy和spock-core到适配3.0的版本:

// 升级groovy到3.0.x版本
testImplementation 'org.codehaus.groovy:groovy-all:3.0.8'
// 替换原来的1.3-groovy-2.5版本,和spock-spring保持适配版本一致
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.0-M3-groovy-3.0'

验证方式

修改配置后执行gradle dependencies --configuration testImplementation命令,检查所有groovy相关依赖的版本是否完全统一。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 20:06:03