docker pull zookeeper
docker run --name zk01 -p 2181:2181 --restart always -d 2e30cac00aca
indicates that zookeeper has been started successfully
Zookeeper and Dubbo• ZooKeeperZooKeeper is a distributed, open source distributed application coordination service. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name services, distributed synchronization, group services, etc.
DubboDubbo is Alibaba's open source distributed service framework. Its biggest feature is that it is structured in a layered manner. This method can decouple (or maximize loose coupling) between each layer.
From the perspective of the service model, Dubbo adopts a very simple model, either the provider provides services, or the consumer consumes services, so based on this, the service provider can be abstracted ( Provider) and service consumer (Consumer) two roles.
##Client (consumer) configuration: Startup class@SpringBootApplication public class ConsumerManagerApplication { public static void main(String[] args) { SpringApplication.run(ConsumerManagerApplication.class, args); } }
@RestController public class ManagerController { @Reference ManagerService managerService; @RequestMapping("/hello") public String hello() { return managerService.hello(); } }
public interface ManagerService { public String hello(); }
dubbo.application.name=consumer-manager dubbo.registry.address=zookeeper://192.168.0.106:2181 server.port=8081
@SpringBootApplication public class ProviderManagerApplication { public static void main(String[] args) { SpringApplication.run(ProviderManagerApplication.class, args); } }
public interface ManagerService { public String hello(); } @Service public class ManagerServiceImpl implements ManagerService { @Override public String hello() { System.out.println("客户端请求进来了!"); return "xixi success !!!"; } }
dubbo.application.name=provider-manager dubbo.registry.address=zookeeper://192.168.0.106:2181 dubbo.scan.base-packages=com.hourui
The above is the detailed content of How to integrate Dubbo zookeeper in SpringBoot. For more information, please follow other related articles on the PHP Chinese website!