Spring Cloud Zookeeper和服務(wù)注冊中心

2023-12-05 16:23 更新

Spring Cloud Zookeeper實(shí)現(xiàn)了ServiceRegistry接口,允許開發(fā)人員以編程方式注冊任意服務(wù)。

ServiceInstanceRegistration類提供了一種builder()方法來創(chuàng)建Registration可以使用的Registration對象,如以下示例所示:

@Autowired
private ZookeeperServiceRegistry serviceRegistry;

public void registerThings() {
    ZookeeperRegistration registration = ServiceInstanceRegistration.builder()
            .defaultUriSpec()
            .address("anyUrl")
            .port(10)
            .name("/a/b/c/d/anotherservice")
            .build();
    this.serviceRegistry.register(registration);
}
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號