博客
关于我
{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/

    你可能感兴趣的文章
    org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
    查看>>
    sqlserver学习笔记(三)—— 为数据库添加新的用户
    查看>>
    org.apache.http.conn.HttpHostConnectException: Connection to refused
    查看>>
    org.apache.ibatis.binding.BindingException: Invalid bound statement错误一例
    查看>>
    org.apache.ibatis.exceptions.PersistenceException:
    查看>>
    org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
    查看>>
    org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
    查看>>
    org.apache.poi.hssf.util.Region
    查看>>
    org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
    查看>>
    org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
    查看>>
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'
    查看>>
    org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    查看>>
    org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
    查看>>
    org.springframework.amqp.AmqpConnectException:java.net.ConnectException:Connection timed out:connect
    查看>>
    org.springframework.beans.factory.BeanDefinitionStoreException
    查看>>
    org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
    查看>>
    org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
    查看>>
    SQL-CLR 类型映射 (LINQ to SQL)
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>