错误报告:
Description:
Field commentMapper in com.qc.qc_blog.service.impl.CommentServiceImpl required a bean of type 'com.qc.qc_blog.mapper.CommentMapper' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.qc.qc_blog.mapper.CommentMapper' in your configuration.
这个错误的原因是Mapper下面的没有加上@Mapper注解 自动配置找不到文件
像下图这样将函数加上@Mapper的注解即可

2021.6.25 草稿箱整理
后记:
这个是前面写的草稿,但是在学习了maven项目的现在又觉得这是一个很浅显的问题了,但是关于service和implement的东西暂时还未弄明白,等后面再来整理和补充

这篇博客讨论了一个Spring Boot应用在运行时遇到的Mapper注入问题。问题源于CommentMapper接口缺少@Mapper注解,导致自动配置无法找到相应的bean。解决方案是在Mapper接口上添加@Mapper注解,以启用MyBatis的自动扫描。此问题对于初学者来说是一个常见陷阱,但理解Spring的依赖注入和MyBatis的配置是避免此类问题的关键。
9363

被折叠的 条评论
为什么被折叠?



