在我的项目中,我有 spring-jdbc:4.1.4.RELEASE
工作正常,没有任何问题。现在,对于新的更改,我尝试添加 spring-security-taglibs:4.0.4.RELEASE
在我的项目中,它试图下载 spring-security-taglibs:4.0.4.RELEASE
和spring-jdbc-4.2.5.RELEASE
,这将在我的项目中造成严重的问题。因为什么spring-jdbc
我需要的版本是4.1.4.RELEASE
我明确指定了。我怎样才能避免这种情况?后面发生了什么?
这是 gradle 的奇怪行为
最佳答案
您的 build.gradle
中似乎有类似的内容:
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-jdbc:4.1.4.RELEASE'
compile 'org.springframework.security:spring-security-taglibs:4.0.4.RELEASE'
}
因此,这会在您的依赖项中引入冲突,这在以下任务的输出中可见:
gradle dependencyInsight --dependency org.springframework:spring-jdbc
:dependencyInsight
org.springframework:spring-jdbc:4.2.5.RELEASE (conflict resolution)
\--- org.springframework.security:spring-security-acl:4.0.4.RELEASE
\--- org.springframework.security:spring-security-taglibs:4.0.4.RELEASE
\--- compile
org.springframework:spring-jdbc:4.1.4.RELEASE -> 4.2.5.RELEASE
\--- compile
上面的箭头(->)表示使用了 gradle 默认解析策略,并且 gradle 选择了 4.2.5(最新)。您可以在 gradle 文档中阅读:
Gradle offers the following conflict resolution strategies:
Newest: The newest version of the dependency is used. This is Gradle's default strategy, and is often an appropriate choice as long as versions are backwards-compatible.
Fail: A version conflict results in a build failure. This strategy requires all version conflicts to be resolved explicitly in the build script.
我认为您可以选择:
- 使用最新的
spring-jdbc
(IMO 最好的) - 使用旧的 spring security 标签库,它依赖于旧的
spring-jdbc
- 解决脚本中的版本冲突(IMO 中最糟糕的情况)并祈祷吧。您至少需要一些运气:-) 详细信息 - here
关于java - Gradle - spring-security-taglibs :4. 0.4.RELEASE 正在内部下载 spring-jdbc-4.2.5.RELEASE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36493572/