解决springboot3接入mybatisplus,报错Bean找不到问题

背景:
拥抱新技术,使用Springboot3.4.1搭建新项目时,接入 Mybatisplus时,一直提示 Bean 找不到,无法注入
报错:

Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
 Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

分析:
网上各种方法都试过了,
1、@MapperScan扫描,
2、配置mybaitsplus

mybatis-plus:
  type-aliases-package: com.***.entity # 实体类包路径

3、springboot版本切换

等等

最后上官网看了下,发现Springboot3以上的版本引入的mybaitsplus的包是

		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
			<version>3.5.9</version>
		</dependency>

而我之前使用IDE默认引入的是

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

这个坑踩了一天,一直试错,也视图通过debug找问题,还好想到官网应该有说明

解决
Springboot3以上版本接入Mybatisplus时需要引入的包为

		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
			<version>3.5.9</version>
		</dependency>

最好看看官网最新的包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值