出现错误

Field userTextMapper in com.springboot.demo.service.UserTextService required a bean of type 'com.springboot.demo.dao.UserTextMapper' that could not be found.

网上解决方案总结

包结构

将启动类放在外层包
SpringBoot启动报错,未找到mapper

注解没有加

SpringBoot启动报错,未找到mapper

配置 mybatis-generator 出现的问题

  1. 启动类加注释:@MapperScan(basePackages = { "mapper所在的包路径" }, sqlSessionFactoryRef = "sqlSessionFactory"),表示扫描xx.xx.mapper包下的所有mapper。
    SpringBoot启动报错,未找到mapper
  2. 直接在你生成出来的xxxMapper.java类上加@Mapper标签。

相关文章: