spring boot 3.0.0 使用gradle7.6整和myabtis-plus 3.5.3.1 出现如下报错

java.lang.ClassCastException: class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext

提示类型转换错误,这是因为mybatis-plus-boot-starter引入了slf4j,与项目中原本的slf4j冲突了,这时候我们需要将slf4j给排除掉。
所以我们需要在build.gradle全局排除slf4j,具体版本可参考外部库中的版本。
在build.gradle中写入如下代码:

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

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐