mybatis自动生成的bean接口在service层找不到
报错如下:
Description:
Field tbItemMapper in com.e3mall.cms.service.cmsServiceImpl required a bean of type
'com.e3mall.cms.dao.mapper.TbItemMapper' that could not be found.
Action:
Consider defining a bean of type 'com.e3mall.cms.dao.mapper.TbItemMapper' in your configuration.
环境:
mapper接口上已经添加了@Component,且pom.xml中不会过滤调xml文件。
原因:
springboot默认不会扫描到对应的bean文件
解决:
方式1、在mapper接口上添加@Mapper
方式2、在application启动类上添加@MapperScan(basePackages = {"com.e3mall.cms.dao.mapper"})