【问题标题】:gradle exclude specific jars from runtime dependenciesgradle 从运行时依赖项中排除特定的 jar
【发布时间】:2023-03-25 11:03:01
【问题描述】:

有没有办法使用 Gradle 从组中排除特定的 jar?我试过下面的代码,但这删除了该组的所有罐子

configurations {
   all*.exclude group: 'org.xxxx.xxxx'
}

我的要求是只从组中删除特定的罐子,而不是所有罐子。我们正在做这个练习来排除系统运行时的传递依赖。

谢谢。

【问题讨论】:

  • 使用compileOnly 依赖集
  • 对于这个特定问题,还要指定module映射键

标签: java gradle build.gradle dependency-management


【解决方案1】:

您可以在依赖项块中排除组中的所有依赖项,或仅排除组中的某些模块:

    dependencies {

        /* --------------  SpringBoot without Tomcat  ------------------- */
        compile('org.springframework.boot:spring-boot-starter-web') {    
            exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
        }

    }

我添加了指向 Gradle 文档的链接,详细解释了传递依赖:https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-19
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2015-05-15
    • 1970-01-01
    • 2018-12-05
    相关资源
    最近更新 更多