• 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却还没有加载!

  • 相关阅读:
    UDP最大传输字节
    [bzoj3994] [SDOI2015]约数个数和
    [bzoj3529] [Sdoi2014]数表
    [bzoj3309] DZY Loves Math
    [bzoj2693] jzptab
    [bzoj4407] 于神之怒加强版
    [bzoj3688] 折线统计
    [bzoj2301] [HAOI2011]Problem b
    [bzoj2820] YY的GCD
    [bzoj4559] [JLoi2016]成绩比较
  • 原文地址:https://www.cnblogs.com/enshrineZither/p/3484534.html
Copyright © 2020-2023  润新知