问题描述
我已经声明了对 org.spockframework:spock-spring:1.1.d91bf785-groovy-2.4
的依赖,但是在运行时范围中它被覆盖为 1.0-groovy-2.4
。
I have declared a dependency for org.spockframework:spock-spring:1.1.d91bf785-groovy-2.4
, but in runtime scope it is overridden to 1.0-groovy-2.4
. Is there a way to figure out which dependency is overriding it?
1.0-groovy-2.4
不存在,该如何解决?本地的任何gradle文件,当我在 shared-config
项目中运行 gradle依赖项
时,该文件不可见。
1.0-groovy-2.4
is not present in any gradle file locally, and it is not visible when I run gradle dependencies
in the shared-config
project.
这里是 main-web
项目中的 gradle依赖项
:
testCompile
[...]
+--- project :shared-config
| [...]
| +--- org.spockframework:spock-spring:1.1.d91bf785-groovy-2.4
[...]
runtime
[...]
+--- project :shared-config
| [...]
| +--- org.spockframework:spock-spring:1.1.d91bf785-groovy-2.4 -> 1.0-groovy-2.4
| | +--- org.spockframework:spock-core:1.0-groovy-2.4 -> 1.1.d91bf785-groovy-2.4
| | \--- org.codehaus.groovy:groovy-all:2.4.1 -> 2.4.12
dependencyInsight
提供了一些见解:
$ gradle dependencyInsight --dependency org.spockframework:spock-spring:1.0-groovy-2.4 --configuration runtime
> Task :main-web:dependencyInsight
org.spockframework:spock-spring:1.0-groovy-2.4 (selected by rule)
org.spockframework:spock-spring:1.1.d91bf785-groovy-2.4 -> 1.0-groovy-2.4
\--- project :shared-config
\--- runtime
但是 shared-config
项目中的相同命令不会产生任何结果:
But the same command in the shared-config
project doesn't yield any results:
No dependencies matching given input were found in configuration ':shared-config:runtime'
$ b $中未找到与给定输入匹配的依赖项b
我尝试覆盖该版本但未成功:
I have tried overriding the version without success:
configurations.all {
resolutionStrategy {
force "org.spockframework:spock-spring:1.1.d91bf785-groovy-2.4"
}
}
推荐答案
似乎您将spring boot用作父项,或者将spring boot依赖项用作bom(依赖管理器)
Seems like you are using spring boot as a parent or spring boot dependencies as a bom (dependency manager)
默认在最新的春季引导版本1.5 + spock.version
中设置为 1.0-groovy-2.4
这就是为什么 spock-core
仍然具有旧版本的原因。
by default in latest spring boot versions 1.5 + spock.version
is set to 1.0-groovy-2.4
that's why spock-core
still have old version.
为了解决此问题,您需要需要覆盖gradle应用中的属性 spock.version
。通过将 spock.version = 1.1-groovy-2.4
添加到 gradle.properties
文件中。
In order to fix this in gradle you need to override property spock.version
in your gradle app. By adding spock.version = 1.1-groovy-2.4
to gradle.properties
file.
访问,以查找更多信息。
Visit Spring doc for overriding dep properties to find more.
这篇关于确定Gradle中依赖版本覆盖的来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!