服务端配置:
server: port: 8888 eureka: instance: hostname: 10.170.9.123 client: register-with-eureka: false # 是否向eureka注册自身服务 fetch-registry: false #是否检索服务 service-url: #服务注册地址 defaultZone: http://${eureka.instance.hostname}:${server.port}/eurekaServer/
客户端配置:
server: port: 8890 eureka: client: fetch-registry: true register-with-eureka: true serviceUrl: defaultZone: http://10.170.9.123:8888/eurekaServer/
这样的配置一直报was unable to refresh its cache! status = Cannot execute request on any known server这样的错。这显然是eureka客户端与服务端信息不通造成的,一直不知道什么原因造成的,后来看到一篇文章(http://www.bubuko.com/infodetail-3047755.html)说是defautlZone地址中端口后面必须是eureka,不能换成其他的即使两个地方保持一致也不行,试了一下,果然是这里的问题