springboot整合@Autowired注入mapper失败

现在博文千篇一律,试了大部分博文问题还是会存在,可能是老天可怜我脑子不好使,终于让我找到一篇简单明了的博文【参考博文】:https://blog.csdn.net/sinat_36710456/article/details/80143986

问题

用springboot注入mapper的时候出现下波浪线的错误,并且提示“Could not autowire. No beans of ‘UserMapper’ type found”
在这里插入图片描述

解决方法

第一步:在application中加入MapperScan的注解,里面写mapper的目录路径
在这里插入图片描述
第二步:在mapper中加入@Repository注解
在这里插入图片描述
最后发现已经没有下波浪线了
在这里插入图片描述

发布了9 篇原创文章 · 获赞 5 · 访问量 1494

猜你喜欢

转载自blog.csdn.net/qq_40060186/article/details/103023318
今日推荐