java - Gradle - spring-security-taglibs :4. 0.4.RELEASE 正在内部下载 spring-jdbc-4.2.5.RELEASE

标签 java spring gradle

在我的项目中,我有 spring-jdbc:4.1.4.RELEASE工作正常,没有任何问题。现在,对于新的更改,我尝试添加 spring-security-taglibs:4.0.4.RELEASE在我的项目中,它试图下载 spring-security-taglibs:4.0.4.RELEASEspring-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.

Link.

我认为您可以选择:

  • 使用最新的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/

相关文章:

android - 如何将特定库 github 提交库集成到 Android 项目中?

java - 如何在java中运行时比较两个长值

java - 启动时引导数据,Spring MVC,Hibernate

amazon-web-services - 使用 Gradle 插件将 docker 镜像推送到 ECR

java - 在生成的事件流值中找不到 Spring 的 SSEmitter 事件 "name"属性

java - 指定每个 Controller 使用哪个 ViewResolver?

gradle - 在 Gradle 中,从所有依赖项中排除传递依赖项,除了一个

java - Elasticsearch 中的索引是什么

java - 循环3个map获取同一个key的值

java - 如何使用Java上传图像Url上传到Fire Storage并同时将其保存在fireStore中