出现错误
Field userTextMapper in com.springboot.demo.service.UserTextService required a bean of type 'com.springboot.demo.dao.UserTextMapper' that could not be found.
网上解决方案总结
包结构
将启动类放在外层包
注解没有加
配置 mybatis-generator 出现的问题
- 启动类加注释:@MapperScan(basePackages = { "mapper所在的包路径" }, sqlSessionFactoryRef = "sqlSessionFactory"),表示扫描xx.xx.mapper包下的所有mapper。
- 直接在你生成出来的xxxMapper.java类上加@Mapper标签。