Field demoDao in com.example.demo.service.impl.DemoServiceImpl required a bean of type 'com.example.demo.dao.DemoDao' that could not be found.
原因:在编译之后没有生成相应的接口实现类
解决办法:
方法一、在每个dao层添加@Mapper注解:
方法二、在启动类添加注解@MapperScan("com.example.demo.dao")
本文解决了一个在使用MyBatis时常见的问题,即在编译后未能找到对应的DAO接口实现类,提供了两种解决方案:一种是在每个DAO层添加@Mapper注解,另一种是在启动类中添加@MapperScan注解。
Field demoDao in com.example.demo.service.impl.DemoServiceImpl required a bean of type 'com.example.demo.dao.DemoDao' that could not be found.
原因:在编译之后没有生成相应的接口实现类
解决办法:
方法一、在每个dao层添加@Mapper注解:
方法二、在启动类添加注解@MapperScan("com.example.demo.dao")
2882
1983
4万+
6万+

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