首页 > 解决方案 > 无法排除依赖 gradle

问题描述

我需要从 io.confluent:kafka-schema-registry:5.3.0 中排除 slf4j 依赖项。我试过使用

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

但我不断收到错误

Cannot set the value of read-only property 'group' for DefaultExternalModuleDependency{group='io.confluent', name='kafka-schema-registry', version='5.3.0', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.

谁能告诉我如何实现这一目标。我尝试了多种方法但无法做到

标签: gradlebuild.gradle

解决方案


for 的语法exclude()不正确。您必须使用:而不是=. exclude()将 aMap作为输入,因此,在 Groovy DSL 中,它必须写为:

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

推荐阅读