我刚刚创建了我的第一个Consul
感知型Spring Boot应用程序,但无法正常工作。
该应用程序非常简单:
@SpringBootConfiguration
@EnableAutoConfiguration
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class);
}
}
spring:
application:
name: exmpl
cloud:
consul:
discovery:
health-check-path: /my-health-check
health-check-interval: 20s
tags: exmplTag
dependencies {
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-consul', version: '2.1.2.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-consul-discovery', version: '2.1.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.1.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.6.RELEASE'
}
我想提到的是,该应用程序已正确发现且属性已正确选择。如您在屏幕截图中所见,标记“ exmplTag”正确显示。
尽管如此,health-check-path
未被暴露,Consul
无法进行健康检查。
这是否意味着我必须自己创建端点或配置不正确?
答案 0 :(得分:0)
默认情况下未设置运行状况检查端点领事,将使用默认的弹簧执行器/health
端点。
因此,您需要添加对弹簧执行器的依赖。
如果您设置自定义健康检查网址,则需要提供该网址(/my-health-check
)。