踩坑记录-001 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文件中,配置文件里路径错误

解决方法

补全注解

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

@Service
一般用于业务层的注解。 作用和component

@Repository
 一般用于持久层的注解。 作用和component


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



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

查看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" />   
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-02 17:28
25届每天都在焦虑找工作的事情0offer情绪一直很低落硬撑着面了一个岗位岗位有应酬的成分面试的时候hr给我出各种场景题问的问题比较犀利&nbsp;有点压力面的感觉感觉有点回答不上来本来就压抑的情绪瞬间爆发了呢一瞬间特别想哭觉得自己特别没用没绷住掉眼泪了事后想想觉得自己挺有病的&nbsp;真的破大防了
喜欢唱跳rap小刺猬...:我觉得没关系吧,之前有一次面试leader给我压力面,我顶住了压力,结果入职的时候发现组里氛围很差,果断跑路。其实从面试就能大概看出组的情况,面试体验好的组倒是不一定好,但是面试体验不好的组。。。就很难说
面试尴尬现场
点赞 评论 收藏
分享
05-26 22:25
门头沟学院 Java
Java小肖:不会是想叫你过去把你打一顿吧,哈哈哈
点赞 评论 收藏
分享
qq乃乃好喝到咩噗茶:院校后面加上211标签,放大加粗,招呼语也写上211
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务