启动报找不到dao类异常

本文探讨了在Spring Boot应用中遇到的异常,原因在于未正确配置ProductMapper接口。解决方法包括指定扫描目录和单独为Mapper接口添加@Repository注解。了解如何避免此类配置错误并确保DAO层的正确注入。
摘要由CSDN通过智能技术生成

异常: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层
解决方法二
单个扫描,把这个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);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值