spring cloud consul配置
阿新 • • 發佈:2020-07-14
配置yaml內容如下:
spring: cloud: consul: host: consul-dev.cmsp-dev.svc.cluster.local port: 8500 discovery: healthCheckInterval: 5s prefer-ip-address: true instanceId: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} health-check-critical-timeout: 30s
pom.xml配置如下:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Hoxton.SR1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-consul-discovery</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies>
consul的健康檢查使用actuator提供的/actuator/health介面。