出現錯誤
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標簽。