@Autowired时出现Could not autowire. No beans of 'XXX' type found.错误解决方法

Spring在自动注入时出现检查异常Could not autowire. No beans of ‘XXX’ type found.

方法一:在Mapper的接口类中
添加@Mapper的同时在上面再加一个@Repository注解
申明Dao类为Bean

方法二:在Service的实现类中
在@Autowired后面添加@Autowired(required = false)参数
表示忽略当前要注入的Bean,如果有直接注入,没有跳过。

发布了3 篇原创文章 · 获赞 0 · 访问量 124

猜你喜欢

转载自blog.csdn.net/Pluto_sang/article/details/104697147
今日推荐