问题描述:
在写dubbo的client端代码时,使用<dubbo:reference interface="" />进行装配时,调用地方直接使用@Resource进行装配注入,程序启动总是报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘subscriptionService‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hpe.bazaar.subscription.dao.SubscriptionDAOAdapter] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(mappedName=, shareable=true, description=, name=, type=class java.lang.Object, lookup=, authenticationType=CONTAINER)}
查了好久都没找到问题,最后终于找到问题。
解决方案:
<dubbo:reference id="" interface="" />
原因分析:
其实是没有真正理解Resource的含义,Resource是把类注入到了另一个类里,并且启动时回去按照类型和id找对应的类装配,由于没有配置Resource的id对应的类型,所以没有找到依赖
时间: 2024-10-19 02:49:55