码迷,mamicode.com
首页 > 编程语言 > 详细

spring的注解Resource和Autowired

时间:2015-12-22 22:58:26      阅读:718      评论:0      收藏:0      [点我收藏+]

标签:

问题描述:

  在写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对应的类型,所以没有找到依赖

spring的注解Resource和Autowired

标签:

原文地址:http://www.cnblogs.com/liushanping/p/5068329.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!