場景:java
在啓動eureka server時,出現如下錯誤: api
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
問題解決:app
查看配置文件application.yml,發現register-with-eureka 屬性值設置爲true了,將其改成false,重啓eureka服務,啓動成功,問題解決fetch
緣由:url
在默認設置下,eureka服務註冊中心也會將本身做爲客戶端來嘗試註冊它本身,因此咱們須要禁用它的客戶端註冊行爲:spa
eureka: instance: hostname: localhost client: register-with-eureka: false fetch-registry: false
總結:.net
如果未禁用eureka服務註冊中心的客戶端註冊行爲,需提供service-url註冊中心地址:code
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/