Closed liangjava closed 6 years ago
Of course, You can append those properties in application.properties:
dubbo.registries.my-registry.address = ...
dubbo.registries.my-registry2.address = ...
And add @EnableDubboConfig(multiple=true)
in your @Configuration
class
springboot2中支持多注册中心。具体做法
springboot版本2.1.0.RELEASE 与dubbo-starter版本
compile group: 'com.alibaba.boot', name: 'dubbo-spring-boot-starter', version: '0.2.0'
Application.java 增加dubbo多注册中心注解 @EnableDubboConfig(multiple = true) 必须加上 ` @SpringBootApplication @EnableDubboConfig(multiple = true) public class Application {
public static void main(String[] args) { SpringApplication.run(Application.class, args); }
} `
application-dev.yml配置.其它dubbo配置写在了主application.yml中啦。
dubbo: protocol: name: dubbo port: 20880 threads: 200 registries: crm-registry: address: localhost:29181 protocol: zookeeper default: true register: false //本地启动时候不希望服务注册到注册中心,则设置register=false;否则可以设置为true或者不设置此参数 mdm-registry: address: 10.19.15.15:29181 protocol: zookeeper
从某个注册中心消费服务的写法
@Reference(version = "1.0.0", check = false, registry = "mdm-registry") ICompanyQuerySv companyQuerySv;
将服务注册到指定注册中心
@Service(version = "1.0.0", registry = "crm-registry") @Slf4j public class ProdSrvTypeTaxRateSvImpl implements IProdSrvTypeTaxRateSv { }
通过xml配置可以实现多个注册中心,如果通过application.properties配置呢? 哪位大神能告知下。谢谢了。