场景:
在启动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/