SpringBoot项目运行报错:org.springframework.beans.factory.BeanNotOfRequiredTypeException

文章描述了一次SpringBoot3.2.3与MyBatisPlus3.5.4.1版本组合时遇到的运行错误,主要问题是由于SpringBoot内置Mybatis版本与MyBatisPlus不兼容。解决方法是将SpringBoot版本降级到3.1.5。
摘要由CSDN通过智能技术生成

SpringBoot项目运行报错:org.springframework.beans.factory.BeanNotOfRequiredTypeException…

image-20240313115221386

版本配置:SpringBoot3.2.3 + MyBatisPlus3.5.4.1

具体报错如下:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with ‘debug’ enabled.
2024-03-13T11:46:38.294+08:00 ERROR 115216 — [ main] o.s.boot.SpringApplication : Application run failed

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’
at org.springframework.beans.factory.support.AbstractBeanFactory.adaptBeanInstance(AbstractBeanFactory.java:410) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:391) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:770) ~[spring-boot-3.2.3.jar:3.2.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:341) ~[spring-boot-3.2.3.jar:3.2.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.3.jar:3.2.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.3.jar:3.2.3]
at com.hgh.security_demo.SecurityDemoApplication.main(SecurityDemoApplication.java:10) ~[classes/:na]

原因: 似乎SpringBoot版本过高,导致其内置的mybatis版本与MyBatisPlus中的版本不兼容导致

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.2.3</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.4.1</version>
</dependency>

解决: 将SpringBoot版本降低为3.1.5

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.5</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.4.1</version>
</dependency>
  • 27
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值