SpringCloud問題解決:spring-cloud-eureka啟動出錯Cannot execute request on any known server
阿新 • • 發佈:2018-04-02
錯誤 registry gis 出錯 行為 exec conn sport 問題解決
場景:
在啟動eureka server時,出現以下錯誤:
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
問題解決:
查看配置文件application.yml,發現register-with-eureka 屬性值設置為true了,將其改為false,重啟eureka服務,啟動成功,問題解決
原因:
在默認設置下,eureka服務註冊中心也會將自己作為客戶端來嘗試註冊它自己,所以我們需要禁用它的客戶端註冊行為:
eureka: instance: hostname: localhost client: register-with-eureka: false fetch-registry: false
總結:
若是未禁用eureka服務註冊中心的客戶端註冊行為,需提供service-url註冊中心地址:
server: port: 8091 eureka: instance: hostname: localhost client: register-with-eureka: true fetch-registry: false #註冊中心地址 service-url: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
SpringCloud問題解決:spring-cloud-eureka啟動出錯Cannot execute request on any known server