SpringBoot项目整合Mybatis-plus出现版本兼容问题——mp版本较高会导致一系列问题

写在前面:springboot整合Mybatis-plus时,引入的Mybatis-plus版本不能太高,否则会出现一系列奇怪的问题。


总结来说:

问题:如果你的项目报错出现如下字样

  • Caused by: org.springframework.beans.factory.BeanCreationException:
  • Caused by: java.io.IOException: Failed to parse mapping resource:
  • Caused by: org.apache.ibatis.builder.BuilderException
  • Caused by: org.apache.ibatis.type.TypeException:
  • org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'ddlApplicationRunner' is expected to be of type 'org.springframework.boot.Runner' but was actually of type 'org.springframework.beans.factory.support.NullBean'
  • java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String

解决方案:也就是出现(ibatis,bean,factory……)等问题,然后你用常规方法debug都失败,那么你可以试试降低引入的mp版本,例如我将将3.5.2降至3.4.2,问题完美解决

以上6个报错,是我在我手中4个不同的springboot项目引入高版本Mybatis-plus后出现的不同问题,不得不感叹:同样一个高版本Mybatis-plus原因,在不同项目中体现的报错也是千奇百怪啊!

原因:精确的原因,我并没有查到准确资料,因为版本兼容性导致的问题本身就多种多样,不能一概而论,但是可以这么理解:Mybatis plus是通过反射,动态代理等技术实现的,包括对一系列bean,bean factory的操作,所以当遇到(ibatis,bean,factory……)的问题,不妨试试降低mp版本!


由于暑期软件开发实习需要,今晚回顾了springboot的一些基本操作,因为是回顾基础知识,所以我选择从零开始构建springboot,但是过程中遇到了一系列很奇怪的问题,GPT和网上都没有恰当的解决方案。

在一步步debug之后,发现去掉Mybatis-plus依赖程序就正常运行,忽然想到应该是因为Mybatis-plus引入的版本太高导致了如下一系列问题呢,随即将3.5.2降至3.4.2,发现问题完美解决,如下报错:

  • java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
  • org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'ddlApplicationRunner' is expected to be of type 'org.springframework.boot.Runner' but was actually of type 'org.springframework.beans.factory.support.NullBean'
  • Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Category'.  Cause: java.lang.ClassNotFoundException: Cannot find class: Category
  • Caused by: org.apache.ibatis.builder.BuilderException
  • Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file 
  • Caused by: java.io.IOException: Failed to parse mapping resource: 'file [D:\Study\java-project\sky-take-out\sky-server\target\classes\mapper\CategoryMapper.xml]'
  • Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource

本人211软件工程大二在读,平时喜欢做做项目,打打比赛。以后也会出一些深度学习,计算机视觉相关的学习分享,如果你喜欢的话,可以点赞或者关注一下,我们共同进步!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

.别止步春天.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值