代码之家  ›  专栏  ›  技术社区  ›  user3105453

如何在Consor中正确注册Spring Boot app(部署到Cloud Foundry)

  •  0
  • user3105453  · 技术社区  · 9 年前

    我遵循以下文档: http://cloud.spring.io/spring-cloud-consul/1.0.x/index.html 并将我的Spring Boot应用程序配置如下:

    spring:
      cloud:
        consul:
          enabled: true
          host: consul.domain.tld
          port:  443
          discovery:
            instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
            fail-fast: false
    

    部署到Cloud Foundry后,该应用程序可以连接到Consor并尝试注册,但Consor的“服务检查”立即失败。

    list = discoveryClient.getInstances("myApp");
    list.get(0) => "http://05c81764-18a4-4905-41a8-b5b8:8080"
    

    我必须如何正确配置我的Spring Boot应用程序,才能在Cloud Foundry中向Consor注册服务?

    1 回复  |  直到 9 年前
        1
  •  1
  •   user3105453    9 年前

    你需要设置 spring.cloud.consul.discovery.hostname

    spring.cloud.consul.discovery.hostname=${vcap.application.uris[0]:localhost}
    spring.cloud.consul.discovery.port=80