Springboot整合Mybatis+Dubbo时服务方启动报错Field XXX required a bean of type XXX that could not be found

今天搭建Springboot项目一直报错Field XXX required a bean of type XXX that could not be found
springboot的配置文件中如果有spring.dubbo.base-package就会报错,去掉就启动成功。
配置文件如下:
Springboot整合Mybatis+Dubbo时服务方启动报错Field XXX required a bean of type XXX that could not be found
报错如下:
Springboot整合Mybatis+Dubbo时服务方启动报错Field XXX required a bean of type XXX that could not be found
因为在service层有用到mapper类,一直加载不到类,所以就报错了。
Springboot整合Mybatis+Dubbo时服务方启动报错Field XXX required a bean of type XXX that could not be found
解决方法: 在主方法加入 @MapperScan 注解,如下,这也是最根本的解决方法
Springboot整合Mybatis+Dubbo时服务方启动报错Field XXX required a bean of type XXX that could not be found
spring.dubbo.base-package:发布服务扫描的路径,如有配置上,项目在启动时就会进行扫描,当扫描不到代码中需要加载的类时就会报错。
@MapperScan:扫描的Mapper类的包的路径。