启动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成功注册