Java踩坑记录-00001 BeanCreationException

异常描述

严重: StandardWrapper.Throwable

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'itemSearchController' defined in file 
[C:\codespace\pinyougou-parent\pinyougou-search-web\target\classes\com\pinyougou\search\controller\ItemSearchController.class]: Initialization of bean failed; nested exception is 

org.springframework.beans.factory.BeanInitializationException:
Failed to init remote service reference at filed itemSearchService in class
com.pinyougou.search.controller.ItemSearchController; nested exception is
java.lang.IllegalStateException: Failed to check the status of the service

com.pinyougou.search.service.ItemSearchService. No provider available for the service
com.pinyougou.search.service.ItemSearchService from the url

zookeeper://192.168.25.135:2181/com.alibaba.dubbo.registry.RegistryService?application=pinyougou-search-web&dubbo=2.8.4&interface=com.pinyougou.search.service.
ItemSearchService&methods=search&pid=8600&revision=0.0.5-SNAPSHOT&side=consumer&timestam
p=1565522609857 to the consumer 192.168.211.1 use dubbo version 2.8.4

异常原因

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

此为注入异常,bean没有实例到spring容器中,查看spring配置,有没有扫到这个bean或配置这个bean

出现该异常一般为以下几点:

  • bean 没有添加注解 或者注解的包引入错误
  • xml文件中,配置文件里路径错误

解决方法

1.补全注解

@Component()
"对象的名称"相当于bean标签的id属性,如果类不属于javaEE三层架构中的任意一层,那么使用就使用@Component
@Controller
一般用于表现层的注解。 作用和component
@Service
一般用于业务层的注解。 作用和component
@Repository
 一般用于持久层的注解。 作用和component


@Autowired
优先根据类型注入数据,如果有唯一的对象,那么就能成功注入.如果没有唯一的对象
那么就自动根据变量名和ioc容器对象的名称进行匹配,如果变量名称都无法对应上,那么就报错

@Reference
@Reference注入的是分布式中的远程服务对象  来自dubbo服务

2.查看xml是否正确

    <dubbo:protocol name="dubbo" port="20884"/>
    
	<dubbo:application name="quasimodo-search-service"/>
    <dubbo:registry address="zookeeper://192.168.25.135:2181"/>
    <dubbo:annotation package="com.quasimodo.search.service.impl" />

转载于:https://my.oschina.net/u/4182917/blog/3089067

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值