SpringBoot整合Dubbo:注册失败问题 No Spring Bean annotating Dubbo's @Service was found under package

启动zookeeper,启动provider,启动consumer之后,访问报错。

There was an unexpected error (type=Internal Server Error, status=500).
No provider available from registry 127.0.0.1:2181 for service com.example.interfaceapi.PeopleService on consumer 172.18.71.53 use dubbo version 2.6.2, please check status of providers(disabled, not registered or in blacklist).

定位问题:

查看zookeeper中注册节点,命令:

./zkCli.sh -server 127.0.0.1:2181

查询zookeeper中注册情况,发现provider没有注册进来。

启动provider,在日志中找到

019-12-24 11:25:56.849  INFO 871 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] BeanNameGenerator bean can't be found in BeanFactory with name [org.springframework.context.annotation.internalConfigurationBeanNameGenerator], dubbo version: 2.6.2, current host: 172.18.71.53
2019-12-24 11:25:56.849  INFO 871 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] BeanNameGenerator will be a instance of org.springframework.context.annotation.AnnotationBeanNameGenerator , it maybe a potential problem on bean name generation., dubbo version: 2.6.2, current host: 172.18.71.53
2019-12-24 11:25:56.852  WARN 871 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] No Spring Bean annotating Dubbo's @Service was found under package[com.example.provider], dubbo version: 2.6.2, current host: 172.18.71.53
20

发现service注入失败

发现provider中的@service标签是:

import org.springframework.stereotype.Service;

dubbo中按照https://dubbo.apache.org/zh-cn/blog/dubbo-annotation-driven.html文档,应该导入的是:

import com.alibaba.dubbo.config.annotation.Service;

重新启动服务,日志正常

zookeeper中校验正常:

provider成功注册

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值