出现以下错误解决方法
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'addAndShowQuestionAction': Unsatisfied dependency expressed through field 'answerService';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'answerService': Unsatisfied dependency expressed through field 'answerDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.dao.IAnswerDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
我的天,纠结了半天,结果是不管你的实体类是继承了类还是接口,都要把@Repository写在最后的实现类上,写在接口上没用,写在父类上也没用

本文详细解析了Spring框架中出现依赖注入失败的具体原因,并提供了解决该问题的有效方法。问题表现为无法创建bean,具体错误信息指出是由于依赖的bean未找到。通过调整@Repository注解的位置至实现类解决了此问题。

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



