Spring Eureka 寻找默认端口 8761 而不是自定义端口

Spring Eureka looking for default port 8761 instead of custom port

我有一个 Spring Boot Eureka 服务器应用程序,它在端口 5000 中配置为 运行 而不是默认端口 8761。但​​是当我 运行 SBA 时,我得到了一些在收听 localhost:8761

时,控制台上出现与 java 连接被拒绝有关的错误

INFO 10408 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server ERROR 10408 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}

com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]

稍后当我调出其他微服务时,我可以看到它们正在 eureka 运行ning 端口 5000 上正确注册。但是为什么应用程序在启动 Eureka 服务器时忽略了配置?

另外,从嵌入的图片可以看出,服务器正在 8761 中查找已注册且不可用的副本。

非常感谢对此的任何解释。

Default port for eureka server is 8761 but you can override it using server.port property in application.properties file or application.yml file. 

For e.g.
(application.properties)
   server.port=5000 
(application.yml)
   server:   
    port: 8761

One more thing, you need to specify following properties too to avoid auto registration of eureka.

**application.properties file:-**

eureka.client.registerWithEureka = false
eureka.client.fetchRegistry = false

**application.yml file :-** 

eureka:
   client:
      registerWithEureka: false
      fetchRegistry: false

It should start your application on port 5000. If you still face any issues, just show your properties or yml file code here.

请像下面这样配置尤里卡服务器。 eureka 服务器也将充当 eureka 客户端。所以服务器尝试将自己注册为客户端并寻找默认端口 8761.

server:
  port: 9000

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:9000/eureka

即使在将 registerWithEureka 和 fetchRegistry 添加为 false 之后,它仍然指向副本 url 的 8761。

eureka.client.registerWithEureka = false 
eureka.client.fetchRegistry = false

问题的根本原因实际上并不是将自身 register/search 注册表属性设置为 false,而是 modify/specify 正确的 serviceUrl 属性。

向 application.properties 添加了以下行,现在我的 Eureka 服务器不指向已注册副本的默认 Eureka 端口 8761 url。

eureka.client.serviceUrl.defaultZone: http://localhost:${server.port}/eureka/