Gradle报告依赖冲突,而我认为我可以通过强制使用特定版本来解决冲突。有人可以说明这一点以及如何在任何情况下强制使用特定版本吗?
这是基本的构建脚本。它应该开箱即用。
apply plugin: 'java'
ext {
version_spring = "4.0.4.RELEASE"
version_jbehave = "3.9.2"
}
repositories {
mavenCentral()
}
configurations.all {
resolutionStrategy {
failOnVersionConflict() ;; (1)
//
// The idea is to force a particular version of Spring
//
force "org:springframework:spring-core:${version_spring}"
force "org.springframework:spring-test:${version_spring}"
}
}
dependencies {
// Transitivily depending on org.springframework:spring-test:3.1.1.RELEASE
// Conflict is not resolved according to Gradle (see below)
compile "org.jbehave:jbehave-spring:${version_jbehave}"
}
基本上我只是称之为“gradle依赖”。但是,我正在投入各种选项以确保我不被任何缓存欺骗。
$ gradle --no-daemon --cache rebuild --recompile-scripts \\ --refresh-dependencies --rerun-tasks dependencies :dependencies [..] FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':dependencies'. > Could not resolve all dependencies for configuration ':compile'. > A conflict was found between the following modules: - org.springframework:spring-core:3.1.1.RELEASE - org.springframework:spring-core:4.0.4.RELEASE * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. [..]
我正在使用最新版本的Gradle:
$ gradle -v ------------------------------------------------------------ Gradle 1.12 ------------------------------------------------------------ Build time: 2014-04-29 09:24:31 UTC Build number: none Revision: a831fa866d46cbee94e61a09af15f9dd95987421 Groovy: 1.8.6 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 Ivy: 2.2.0 JVM: 1.8.0 (Oracle Corporation 25.0-b70) OS: Mac OS X 10.8.5 x86_64
答案 0 :(得分:2)
构建脚本中存在拼写错误 - org:springframework
应为org.springframework
。修正拼写错误应解决问题。
答案 1 :(得分:0)
您是否再次使用Java 1.8.0_05而不是使用旧的测试版?好奇。
另外,当您尝试使用Spring 3.2.8而不是4.0.4版本时,您会得到什么?