Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。
作者:mmseoamin日期:2024-02-20

springboot整合mybatisplus时遇见报错

Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。,第1张

Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。,第2张

错误信息:

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.3.jar:6.1.3]

解决方法:

 原因是pom文件中的配置不兼容导致:(以下是错误的、buji)

Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。,第3张

Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。,第4张

修改之后:

Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。,第5张 Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。,第6张

之后问题就解决了; 

问题分析:

实际上 Spring Boot 的版本号通常采用 X.Y.Z 的形式,其中 X 是主版本号,Y 是次版本号,Z 是修订版本号,为了确保最佳的兼容性和功能性,建议使用相同主版本的Spring Boot和MyBatis Plus。例如,您可以考虑使用Spring Boot至3.2.2版本的最新修订版(如3.2.2.RELEASE),并使用MyBatis Plus的最新稳定版本(如3.5.3.2)

Spring Boot 3.2.x与MyBatis Plus 3.5.x系列版本是兼容的