springcloud-订单服务入驻zookeeper
刚才支付在zookeeper注册了,现在搞个订单服务注册并去调用支付。
1.创建模块
2.引入依赖
3.改配置
server: port: 80 # 服务别名---zookeeper注册中心名称 spring: application: name: cloud-consumer-order cloud: zookeeper: connect-string: 192.168.xx.xxx:2181
4.主启动
5.写业务
@RestController @Slf4j public class OrderController { //支付服务地址 public static final String ZK_URL = "http://cloud-provider-payment"; @Resource private RestTemplate restTemplate; @GetMapping("/consumer/payment/zk") public String getpaymentInfo(){ String returnValue = restTemplate.getForObject(ZK_URL+"/payment/zk", String.class); return returnValue; } }
6.测试