Eureka preferredIpAddress:true不适用于Spring Boot 2.1.3'Greenwich.RELEASE''

时间:2019-09-26 08:24:50

标签: spring-boot netflix-eureka spring-cloud-netflix

由于某些原因,我希望微服务客户端使用其IP地址而不是主机名注册到Eureka。 即使设置了eureka:实例:preferredIpAddress:true [在下面给出了Yaml],这也无法正常工作。 仍然eureka仅显示主机名。任何人都面临此类问题,可能的补救措施将非常有帮助。 Springbootversion:2.1.3,Spring云-Greenwich版本

微服务实例的application.yml 请注意preferredIpAddress:true

spring:
  profiles: default
  application:
    name: booking
  cloud:
    config:
      uri: http://localhost:8888,http://localhost:8889

eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true  
    serviceUrl:
      defaultZone: http://localhost:8761/eureka
    healthcheck:
      enabled: false
  instance:
    leaseRenewalIntervalInSeconds: 1
    leaseExpirationDurationInSeconds: 2
    preferIpAddress: true

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
  security:
   enabled: false

Eureka服务器的application.yml

spring:
  profiles: localpeer1

eureka:
  server:
  client:
    register-with-eureka: false
    fetch-registry: false
    serviceUrl:
      defaultZone: http://localhost:8762/eureka

server:
  port: 8761

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

---
spring:
  profiles: localpeer2
eureka:
  server:
  client:
    register-with-eureka: false
    fetch-registry: false  
    serviceUrl:
      defaultZone: http://localhost:8761/eureka

server:
  port: 8762

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

Eureka的仪表板仍显示主机名而不是IP地址。

感谢您的投入。

0 个答案:

没有答案