是否可以在Springboot弹簧执行器健康端点中停用MongoHealthIndicator?

ale*_*a.s 11 spring spring-boot

在我工作的springboot项目中,有一个对spring-data-mongodb的传递maven依赖.因此,MongoHealthIndicator似乎会自动激活,尽管该项目实际上并没有使用mongodb.是否可以在不停用执行器健康终点的情况下专门停用此HealthIndicator?我找到的解决方法是排除依赖关系.但我想知道是否有可能对MongoHealthIndicator进行特定的停用.

ran*_*ing 18

从:

http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

# HEALTH INDICATORS (previously health.*)
...
management.health.mongo.enabled=true
...
Run Code Online (Sandbox Code Playgroud)

您应该能够将其设置为false以禁用运行状况指示器.来自org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration.java

@Configuration
@ConditionalOnBean(MongoTemplate.class)
@ConditionalOnProperty(prefix = "management.health.mongo", name = "enabled", matchIfMissing = true)
public static class MongoHealthIndicatorConfiguration {
Run Code Online (Sandbox Code Playgroud)


jst*_*jst 6

在您的 application.properties 中试试这个

management.health.mongo.enabled=false
Run Code Online (Sandbox Code Playgroud)