✅ 操作成功!

解决问题:Consider defining a bean of type ‘com.xxx.mapper.xxxMapper‘ in your configuration.

发布时间:2023-06-12 作者:admin 来源:文学

解决问题:Consider defining a bean of type ‘com.xxx.mapper.xxxMapper‘ in your configuration.

解决问题:Consider defining a bean of type ‘com.xxx.mapper.xxxMapper‘ in your configuration.

错因:

               mapper层未被加载

   创建一个springboot + mybatis的项目时,于是我发现在mapper层无法访问mysql数据库,也就是说springboot 无法加载到我们的mapper层!

 

有2种解决方案:

               1.在你的mapper层打上mapper注解     

               2.在你的主程序打上ComponentScan注解并指定文件夹 

 1.在你的mapper层打上mapper注解     

 2.在你的主程序打上ComponentScan注解并指定文件夹

注意:若使用的springboot开发的多模块项目,前后端分离项目即第二种不可用,因为分出很多模块,springboot找不到其他模块下的mapper层,则使用第一种方案最佳!

👁️ 阅读量:0