异常:Consider defining a bean of type ‘com.xxx.xxx.dao.ProductMapper’ in your configuration.
具体异常:
Description:
Field productMapper in com.xxx.xxx.service.impl.CommonServiceImpl required a bean of type 'com.xxx.xxx.dao.ProductMapper' that could not be found.
Action:
Consider defining a bean of type 'com.xxx.xxx.dao.ProductMapper' in your configuration.
Disconnected from the target VM, address: '127.0.0.1:61934', transport: 'socket'
Process finished with exit code 1
原因是没有扫描到dao层的接口
解决方法一
红色框框部分是扫描这个目录下的dao层

解决方法二
单个扫描,把这个dao交个spring管理
@org.apache.ibatis.annotations.Mapper
@Repository
@org.apache.ibatis.annotations.Mapper
public interface ProductMapper {
/**
* 查询列表
* @param map
* @return
*/
List<Product> getList(Map<String, Object> map);
}
本文探讨了在Spring Boot应用中遇到的异常,原因在于未正确配置ProductMapper接口。解决方法包括指定扫描目录和单独为Mapper接口添加@Repository注解。了解如何避免此类配置错误并确保DAO层的正确注入。
2013

被折叠的 条评论
为什么被折叠?



