博客
关于我
{spring.cloud.client.ipAddress}
阅读量:644 次
发布时间:2019-03-14

本文共 631 字,大约阅读时间需要 2 分钟。

在Spring Cloud中配置服务实例ID时,默认情况下服务实例ID由主机名、应用名和端口组成。为了自定义实例名可以通过以下步骤进行:

  • 默认配置:默认服务实例ID格式为${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}

  • 自定义配置:在Eureka配置中自定义实例ID。例如,设置实例ID为主机IP地址及端口:

    eureka.instance.instance-id= ${spring.cloud.client.ipAddress}:${server.port}eureka.instance.prefer-ip-address=true
  • 此时,实例ID变为主机IP地址加端口,例如192.168.1.1:8080

    1. 解决访问问题:然而,自定义后可能发现客户端仍指向主机名,无法访问。解决方法是设置eureka.instance.hostname为主机IP地址:
      eureka.instance.hostname= ${spring.cloud.client.ipAddress}
    2. 这样,Eureka将使用IP地址作为实例主机名,实例ID变为IP地址加端口,可由客户端通过IP访问。

      通过以上配置,Instantiation过程如清晰明了,读者能恰知如何逼Sphere Cloud服务直治问题。

    转载地址:http://wwgoz.baihongyu.com/

    你可能感兴趣的文章
    OA项目之我的会议(会议排座&送审)
    查看>>
    OA项目之我的会议(查询)
    查看>>
    OA项目之我的审批(会议查询&会议签字)
    查看>>
    OA项目之项目简介&会议发布
    查看>>
    Object c将一个double值转换为时间格式
    查看>>
    object detection之Win10配置
    查看>>
    object detection训练自己数据
    查看>>
    object detection错误Message type "object_detection.protos.SsdFeatureExtractor" has no field named "bat
    查看>>
    object detection错误之Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
    查看>>
    object detection错误之no module named nets
    查看>>
    Object of type 'ndarray' is not JSON serializable
    查看>>
    Object Oriented Programming in JavaScript
    查看>>
    object references an unsaved transient instance - save the transient instance before flushing
    查看>>
    Object 类的常见方法有哪些?
    查看>>
    Object-c动态特性
    查看>>
    Object.assign用法
    查看>>
    Object.create
    查看>>
    Object.defineProperty详解
    查看>>
    Object.keys()的详解和用法
    查看>>
    objectForKey与valueForKey在NSDictionary中的差异
    查看>>