报错信息:
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注解默认是类名以一个首字母小写注入容器 写成大写当然找不到啦!
正确写法:
<!-- 声明需要暴露的服务接口 -->
<dubbo:service interface="cn.e3mall.service.ItemService" ref="itemServiceImpl" />
<dubbo:service interface="cn.e3mall.service.ItemCatService" ref="itemCatServiceImpl" />
成功!