Injection of resource dependencies failed解决办法总结

原文地址为: Injection of resource dependencies failed解决办法总结

今天调试项目代码,出现的引resource的报错,查原因查了好长时间才找到,现在这里总结一下,以免以后忘掉以及给大家参考。

报错大致内容入下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBlackListService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wondershare.router.dao.CustomBlackListDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}

 找不到依赖的dao,什么原因,spring3 自动注解的,为什么找不到?

找了很多资料,常见的有下面这个:

1、beans 的xml里面没有配置 
<context:component-scan base-package="package-name"/>

2、第二种情况(调用死循环)

很遗憾,我的不是这个问题,我的问题是dao的调用出现死循环,即XyyyyDao实现里面,调用了他接口的本身方法:

@Repository
public class ADaoImpl extends BaseDaoImpl implements ADao {

   @Resource
    private ADao aDao;

    @Override
    public int addInbox(TInbox inbox) {
        ....
        ......
        aDao.delete(id);
    }
   @Override
    public int delete(Long id) {
        .....
    }
}

导致,加载ADaoImpl需要先加载完ADao,而ADao却还没有加载!


转载请注明本文地址: Injection of resource dependencies failed解决办法总结
报错"Injection of resource dependencies failed"意味着依赖对象注入失败。产生这个错误的原因可能有两个:没有装配要注入的类,或者注入的是实现类而不是接口。解决方案如下: 1. 检查是否正确装配了要注入的类。确保在配置文件或注解中正确指定了要注入的类。 2. 如果注入的是接口,请确保注入的类实现了该接口。如果注入的是实现类,可以尝试将注入的对象改为接口类型。 通过以上解决方案,可以解决"Injection of resource dependencies failed"的报错。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Injection of resource dependencies failed—方法增强时的报错原因与解决](https://blog.csdn.net/han1101282993/article/details/87174318)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [Springboot3.1整合mybatis-plus报错:Injection of resource dependencies failed/Property ...](https://blog.csdn.net/qq_61407171/article/details/130970040)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值