zoukankan      html  css  js  c++  java
  • 关于Eureka 服务注册列表显示IP问题研究

    前言:

    在研究Spring Cloud的过程中,本地搭建好Eureka注册中心之后,发现Eureka服务页面显示的服务是机器名:端口的格式,并不是IP+端口的形式。 

    如下图: 
    image_1bhrl17qpgc91cin1gum8bi1g6s9.png-28.2kB

    配置如下:

    spring.application.name=compute-service
    server.port=2223
    eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/

    后来查找相关配置发现,单单配置这个是不够的,以下是最终的配置:

    spring.application.name=compute-service
    server.port=2223
    spring.cloud.client.ipAddress=192.168.43.177
    eureka.instance.prefer-ip-address=true
    eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${spring.application.name}:${server.port}
    eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/

    附结果图: 
    image_1bhu7nsemqg614u71ldl7u1unp9.png-21.2kB

    注意:

    spring cloud不同版本的配置可能不同,比较老的版本是eureka.instance.preferIpAddress=true替代eureka.instance.prefer-ip-address=true 

    在实际的使用过程中,我发现eureka.instance.prefer-ip-address=true其实并不是必须的,只要配置:

    spring.cloud.client.ipAddress=192.168.43.177
    eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${spring.application.name}:${server.port}

    即可显示IP+端口,不过保险起见,建议使用完整配置。

     

  • 相关阅读:
    code light
    asp.net(C#)定时自动发送邮件
    示例代码(一)
    devExpress 7.2.5
    使用VSIUAL C#.NET操作Excel -把DataTable中的数据写入Excel
    C#日期格式化的几种处理方法
    配置
    关于Windows 2008 R2 Web服务器环境搭建、安全流程
    安全
    FTP 用户目录病隔离
  • 原文地址:https://www.cnblogs.com/ZJOE80/p/11190506.html
Copyright © 2011-2022 走看看