前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >mybatis 报错 ClassNotFoundException org.mybatis.logging.LoggerFactory

mybatis 报错 ClassNotFoundException org.mybatis.logging.LoggerFactory

作者头像
jgrass
发布2024-12-25 16:32:48
发布2024-12-25 16:32:48
10900
代码可运行
举报
文章被收录于专栏:蔻丁杂记蔻丁杂记
运行总次数:0
代码可运行

Spring boot 整合 mybatis 报错 ClassNotFoundException org.mybatis.logging.LoggerFactory

直接原因

以下两个依赖会冲突,有了 mybatis-plus-boot-starter,就不需要 spring 自己的 mybatis-spring-boot-starter 了。

代码语言:javascript
代码运行次数:0
复制
<dependency>    <groupId>org.mybatis.spring.boot</groupId>    <artifactId>mybatis-spring-boot-starter</artifactId></dependency>
<!-- mybatis-plus--><dependency>    <groupId>com.baomidou</groupId>    <artifactId>mybatis-plus-boot-starter</artifactId>    <version>3.1.0</version></dependency>

直接删除 mybatis-spring-boot-starter 的引用就OK。

Mybatis-Plus 从 3.0.7.1 更新到 3.1.0(Spring Boot 2.1.3.RELEASE)时启动出现 java.lang.ClassNotFoundException: org.mybatis.logging.LoggerFactory · Issue #885 · baomidou/mybatis-plus

没有找到 mybatis-spring-boot-starter 的依赖?

有趣的问题是,pom.xml 中没有直接找到 mybatis-spring-boot-starter 的依赖,那么,很有可能是其它项目依赖了 mybatis-spring-boot-starter,把这个依赖带了进来。

使用 mvn denpendecy:tree 就可以分析出来,是谁依赖了 mybatis-spring-boot-starter

比如,我这里的情况就是,另一个项目依赖了 mybatis-spring-boot-starter

怎么解?

使用 exclusion 排除掉就可以啦。

如果有多个包依赖了 mybatis-spring-boot-starter,都需要排除。

代码语言:javascript
代码运行次数:0
复制
<dependency>    <groupId>com.xxx.xxx</groupId>    <artifactId>xxx-open-api</artifactId>    <exclusions>        <exclusion>            <artifactId>mybatis-spring-boot-starter</artifactId>            <groupId>org.mybatis.spring.boot</groupId>        </exclusion>    </exclusions></dependency>

如果是多工程的项目,使用 mvn dependency:tree 出现错误,可以参考这个:

[笔记] 多模块 maven 工程中,mvn dependency

分析,jar 包找不到的问题处理。

参考链接:

原文链接: https://cloud.tencent.com/developer/article/2481492

本作品采用 「署名 4.0 国际」 许可协议进行许可,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020年6月11日 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 直接原因
  • 没有找到 mybatis-spring-boot-starter 的依赖?
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档