今天学习使用dubbo时报如下错误,没有找到dubbo注册中心
Caused by: java.lang.IllegalStateException: No such any registry to refer service in consumer 192.168.48.1 use dubbo version 2.6.0, Please add <dubbo:registry address="..." /> to your spring config. If you want unregister, please set <dubbo:service registry="N/A" />
at com.alibaba.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:120) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.AbstractInterfaceConfig.loadRegistries(AbstractInterfaceConfig.java:160) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:378) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:333) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:163) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:59) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.spring.boot.DubboConsumerAutoConfiguration$1.postProcessBeforeInitialization(DubboConsumerAutoConfiguration.java:89) ~[dubbo-spring-boot-starter-2.0.0.jar:na]
... 18 common frames omitted
解决办法:
错误提示可以解决
1.使用直连模式
spring:
dubbo:
registry: N/A
2.使用注册中心
spring:
dubbo:
registry: zookeeper://192.168.48.5:2181
如果你已经配置了以上一种方式,但是仍然报该错误,那么请你仔细检查你的配置文件(我因为yml缩进格式不对导致该错误,配置任何的注册中心都指向了本地地址)