【问题标题】:How to exclude a dependency coming from spring boot in gradle如何在gradle中排除来自spring boot的依赖项
【发布时间】:2022-01-17 16:30:20
【问题描述】:

我的项目有 spring boot 2.3.0.RELEASE 依赖项,因此我们有某些 log4j 依赖项,例如 org.apache.logging.log4j:log4j-api:2.13.2 通过它进入我们的依赖项。

我想从我们的依赖树中排除它。 问题是我们在 ext 块中添加了 spring 依赖

buildscript {
  ext {
    springBootVersion = '2.3.0.RELEASE'
    sonarqubeVersion = '2.7.1'
    gradleOSpackage = '1.9.4'
    jfrogVersion = '2.2.4'
    asciidoctorVersion = '1.5.8.1'
  }  

当我在实现块中有依赖项时,我会排除不需要的依赖项,例如

implementation ('io.confluent:kafka-schema-registry:5.3.0') {
        exclude(group='org.slf4j',module='slf4j-loh4j12')
    }

但是在这种情况下,我不知道如何从 spring boot 中排除即将到来的 log4j 依赖项。

【问题讨论】:

    标签: spring-boot gradle log4j


    【解决方案1】:

    如果它是一个传递依赖,并且我们确定要完全排除它,可以使用 build.gradle 文件中的configurations.all 块,如下所示:

    configurations.all {
      exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
    }
    

    【讨论】:

      猜你喜欢
      • 2017-07-05
      • 2017-11-11
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-08
      • 2016-09-17
      相关资源
      最近更新 更多