From 39c7abc8256e85257c226c87de7f79cb721ad6c2 Mon Sep 17 00:00:00 2001 From: javahongxi Date: Wed, 22 May 2019 10:22:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E4=BA=8E@Reference=E7=9A=84registry?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java | 5 ++++- .../src/main/resources/application.yml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java index c7c66945..8e2af395 100644 --- a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java +++ b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java @@ -12,7 +12,10 @@ import org.springframework.stereotype.Component; @Component public class DemoRpc { - @Reference(check = false) + /** + * 当不指定registry时,Reference会从所有含有该service的registry里选择一个registry + */ + @Reference(registry = "defaultRegistry", check = false) private DemoService demoService; @Reference(registry = "otherRegistry", check = false) diff --git a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/resources/application.yml b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/resources/application.yml index 44d31e93..c622a7ec 100644 --- a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/resources/application.yml +++ b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/resources/application.yml @@ -6,7 +6,7 @@ dubbo: registry: protocol: zookeeper address: 127.0.0.1:2181 - id: my-registry + id: defaultRegistry protocol: port: 20882 name: dubbo -- GitLab