springBoot+mybatis plus项目测试类无法注入bean

问题遇到的现象和发生背景

运行结果:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.itheima.ApplicationTests': Unsatisfied dependency expressed through field 'bookDao': No qualifying bean of type 'com.itheima.dao.BookDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

问题描述:

1、项目结构:

img


2、pom 配置:

img


3、application.yml 配置

img


4、main方法主类

img


5、BookDao接口:

img


6、实体类:

img


7、ApplicationTests测试类:

img

运行结果及详细报错内容

img

我已尝试的方法,和思路:

mysql没有问题,整合mybatis成功连接。现在,springboot整合 Mybatis-plus 就出现无法注入bean.
在BookDao接口 加@Mapper 无法注入bean。后来,我想在 Application 的main方法主类上 @MapperScan("com.itheima.dao"),依然无法注入bean。需要在ApplicationTests测试类,测试。
请问,谁可以指点一下,什么问题么?

按照一下调整试试,如果不行,私信我远程快速搞
1、ApplicationTests 测试类前面增加一个public关键字
2、Book类是增加@TableName注解指定表明
3、ApplicationTests 中测试方法 曾public关键字
4、启动类上怎么@MapperScan注解

springboot测试环境无法注入bean问题分析及解决方案
如有帮助,望采纳
https://blog.csdn.net/qq_39893313/article/details/82945995

  1. Application 加上看看
@MapperScan(basePackages = {"com.wochanye.mp.mapper"})
  1. 配置文件加上
mybatis-plus:
  # xml文件位置
  mapper-locations:
    - classpath*:com/wochanye/mp/mapper/xml/*.xml
  # 实体类位置
  type-aliases-package: com.wochanye.mp.entity