1.環境java
spring-boot 2.1.3 依賴項:spring-cloud-starter-zookeeper-discovery 版本2.1.1web
使用的zookeeper3.4.11spring
代碼以下:app
package com.example.demo; import java.net.InetAddress; import java.net.UnknownHostException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @Configuration @EnableAutoConfiguration @EnableDiscoveryClient @RestController public class ZkDiscoveryApplication { @RequestMapping("/") @ResponseBody String home() { String message = "Hello World from Greeting Microservice located at %s!"; try { String address = InetAddress.getLocalHost().getHostAddress(); message = String.format(message, address); } catch (UnknownHostException e) { message = String.format(message, "Unknown Host"); } return message; }
2.啓動spring boot項目報錯spring-boot
Thrown "KeeperErrorCode = Unimplemented for /services" exceptionspa
3.緣由.net
Curator 和zookeeper的版本不一致code
4.解決方式orm
zookeeper升級到最新的5.x後異常消失blog