Spring Boot 启动失败:找不到 Mapper Bean 的解决方案
一、报错内容
*************************** APPLICATION FAILED TO START *************************** Description: Parameter 0 of constructor in com.xxx.service.impl.UserSocialServiceImpl required a bean of type 'com.xxx.mapper.user.UserSocialMapper' that could not be found. Action: Consider defining a bean of type 'com.xxx.mapper.user.UserSocialMapper' in your configuration.二、报错说明
该错误表示 Spring 无法找到UserSocialMapper类型的 Bean,导致UserSocialServiceImpl的构造函数注入失败。
常见原因:
- Mapper 接口未被扫描:未配置
@MapperScan或扫描路径不正确 - XML 映射文件的 namespace 与接口包路径不一致
- MyBatis 配置问题:ma