news 2026/4/16 16:00:27

Springboot3整合myBatisplus报错:Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.sprin

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Springboot3整合myBatisplus报错:Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.sprin

1、错误:

我用Springboot3.1.7整合myBatisplus3.5.3时,出现下面的错误:

Bean named ‘ddlApplicationRunner’ is expected to be of type ‘org.springframework.boot.Runner’ but was actually of type ‘org.springframework.beans.factory.support.NullBean’

明明我的代码刚开始写,就起了一个头,竟然报错了!

demo框架如下:

(1)Demo1Application.java

(2)controller层:JOJOController.java

(3)service层:JOJOService.java

(4)mapper层:JOJOMapper.java

(5)数据库实体类:jojo.java

(6)pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.1.7</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo1</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo1</name> <description>demo1</description> <properties> <java.version>17</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.3</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> <builder>paketobuildpacks/builder-jammy-base:latest</builder> </image> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project>

是不是看起来非常正确!!没感觉有什么问题,有很多博客说要加上@MapperScan(“com.example.demo1.mapper”)之类的,但是我是加上了,还是有错误。

坑就在于springboot3.1.7需要更高版本的myBatisPlus!

2、解决办法:

把myBatisplus的版本升级到3.5.5,就可以了!!!

<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.3</version> </dependency>

改为

<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.5</version> </dependency>
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/12 15:02:27

SpringBoot3整合FastJSON2如何配置configureMessageConverters

在 Spring Boot 3 中整合 FastJSON 2 主要涉及到以下几个步骤&#xff0c;包括添加依赖、配置 FastJSON 作为 JSON 处理器等。下面是详细的步骤&#xff1a; 1. 添加依赖 首先&#xff0c;你需要在你的 pom.xml 文件中添加 FastJSON 2 的依赖。以下是 Maven 依赖的示例&#…

作者头像 李华
网站建设 2026/4/16 14:32:41

SpringBoot 项目如何使用 pageHelper 做分页处理 (含两种依赖方式)

分页是常见大型项目都需要的一个功能&#xff0c;PageHelper是一个非常流行的MyBatis分页插件&#xff0c;它支持多数据库分页&#xff0c;无需修改SQL语句即可实现分页功能。 本文在最后展示了两种依赖验证的结果。 文章目录 一、第一种依赖方式二、第二种依赖方式三、创建数…

作者头像 李华
网站建设 2026/4/12 20:20:47

发布-订阅模式:流处理架构中的瑞士军刀

你好&#xff0c;我是程序员贵哥。 今天我想要与你分享的是在处理大规模数据中十分流行的一种设计模式&#xff1a;发布/订阅模式&#xff08;Publish/Subscribe Pattern&#xff09;&#xff0c;有些地方也称它为Pub/Sub。 在了解发布/订阅模式之前&#xff0c;我想先简单介…

作者头像 李华
网站建设 2026/4/16 3:59:19

Keil5乱码问题排查:编码一致性核心要点

Keil5中文注释乱码&#xff1f;一文讲透编码根源与实战解决你有没有遇到过这样的场景&#xff1a;在Keil5里打开一个C文件&#xff0c;明明昨天还清清楚楚的“初始化GPIO引脚”&#xff0c;今天却变成了“鍒濆鍖朞PIO寮曡剼”&#xff1f;或者更离谱地显示成一堆方框、问号&a…

作者头像 李华
网站建设 2026/4/16 14:29:31

利用HAL库实现浮点数据转换示例

从ADC采样到真实世界&#xff1a;用HAL库搞定浮点转换的那些事 你有没有遇到过这样的场景&#xff1f; 接上一个温度传感器&#xff0c;读出来的数值明明是12位ADC原始值&#xff08;比如 3056 &#xff09;&#xff0c;但你想知道的是“现在室温到底是23.7℃还是24.1℃”。…

作者头像 李华
网站建设 2026/4/16 12:51:54

AI智能体进化:学习与MCP协议实战

智能体的“自我修炼”与“通用接口”&#xff1a;学习适应与MCP协议实战解析 在智能体从“被动执行”走向“主动智能”的进化中&#xff0c;“学习与适应”是其突破预设局限的核心能力&#xff0c;而“模型上下文协议&#xff08;MCP&#xff09;”则是其打通外部世界的关键桥梁…

作者头像 李华