Bra*_*lle 2 spring-boot consul spring-cloud
我正在将 Spring Boot 应用程序作为 Docker 容器运行。到目前为止,这工作得很好,但是当我尝试使用 Spring Cloud Consul 时,它也让我有些头痛。它可以很好地从 Consul KVS 读取配置,但健康检查似乎正在运行。
默认运行状况检查使用 docker 容器的主机名,例如http://users-microservice/health。显然,从领事访问时这不会解决。
没问题,文档提到您可以在 bootstrap.yml 文件中使用healthCheckPath来配置它。这就是我现在所拥有的:
spring:
application:
name: users-microservice
cloud:
consul:
host: myserver.com
port: 8500
config:
prefix: API-CONFIG
profileSeparator: '__'
discovery:
tags: users-microservice
healthCheckPath: http://myserver.com:${server.port}/status
healthCheckInterval: 30s
Run Code Online (Sandbox Code Playgroud)
不幸的是,这个变量的使用方式似乎与我预期的非常不同。这就是领事试图达到的目标:
Get http://users:18090http//myserver.com:18090/status: dial tcp: unknown port tcp/18090http
我怎样才能解决这个问题?我应该设置一些未记录的配置参数吗?
使用spring.cloud.consul.discovery.healthCheckUrl=http://myserver.com:${server.port}/status
healthCheckPath只更改路径,不更改主机和端口。
| 归档时间: |
|
| 查看次数: |
6424 次 |
| 最近记录: |