1. 程式人生 > >Spring Boot專案啟動報錯com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connec

Spring Boot專案啟動報錯com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connec

報錯內容:

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

原因如下:

在預設設定下,Eureka服務註冊中心也會將自己作為客戶端來嘗試註冊它自己,所以我們需要禁用它的客戶端註冊行為。

禁止方式如下:在application.properties

配置檔案中增加以下內容

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

重啟專案即可