bean创建失败Error creating bean withxx

问题:

Error creating bean with name ‘studentController’: Injection of resource dependencies failed;
BeanCreationException: Error creating bean with name ‘studentController’: Injection of resource dependencies failed;
“Error creating bean with name ‘studentController’: Injection of resource dependencies failed;”问题的原因有很多,最常见的就是缺少注解了。
如果是缺少注解还可能会提示如下错误:
A component required a bean of type ‘com.example.demo2.service.StudentService’ that could not be found.
在这里插入图片描述

解决方案

问题的原因有很多,我之前有次是只报“Error creating bean with name ‘studentController’: Injection of resource dependencies failed;”,我当时删删改改就好了,就有点玄。

但如果是图片中的情况,那必然是缺少注解了,在Spring中,注解(如@Component、@Service、Repository、@Controller等)用于标记类作为Spring容器管理的bean。如果你的控制器类或它的依赖类缺少这些注解,或者注解使用错误,都会导致bean创建失败。

确保你的控制器类和所有依赖的类都使用了正确的注解,并且这些注解的位置也是正确的(通常在类定义之前)。
这里附上有关大佬的链接,

解决Spring框架中‘Error creating bean with name ‘xxxxxxxController’: Injection of resource dependencies failed’错:”

解决 No qualifying bean of type 问题

最新版,已解决!Error creating bean with name ‘xxxxxxxController‘: Injection of resource dependencies failed:

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值