You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle无法排除io.confluent:kafka-schema-registry的slf4j依赖问题

问题原因
  • 语法错误:Gradle 中 exclude 方法接收Map类型参数,Groovy语法里传递Map参数时键值对应使用冒号:而非等号=,你用等号相当于尝试给只读属性group直接赋值,所以触发只读属性报错。
  • 依赖名称拼写错误:你写的slf4j-loh4j12是拼写错误,正确的slf4j log4j绑定依赖名是slf4j-log4j12。
正确写法

写法1:Map参数形式(推荐)

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

写法2:闭包配置形式

implementation ('io.confluent:kafka-schema-registry:5.3.0') {
    exclude {
        group = 'org.slf4j'
        module = 'slf4j-log4j12'
    }
}
全局排除扩展(可选)

如果需要全局排除所有依赖引入的该slf4j包,可以在build.gradle的configurations块统一配置:

configurations {
    implementation {
        exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    }
}

内容的提问来源于stack exchange,提问作者Aman Kumar Sinha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 21:09:04