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

报错信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.e3mall.service.ItemCatService': Cannot resolve reference to bean 'ItemCatServiceImpl' while setting bean property 'ref'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'ItemCatServiceImpl' is defined

仔细推敲原因无非两个:
1.没有加注解或注解加错位置
2.配置文件报扫描范围有问题或dubbo发布有问题

@service注解默认是类名以一个首字母小写注入容器 写成大写当然找不到啦!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.e3ma

正确写法:

  <!-- 声明需要暴露的服务接口 -->
    <dubbo:service interface="cn.e3mall.service.ItemService" ref="itemServiceImpl" />
    <dubbo:service interface="cn.e3mall.service.ItemCatService" ref="itemCatServiceImpl" />

成功!

上一篇:关于@Configuration注解的思考


下一篇:依赖引起的错误