1.什么是Spring Boot的健康检查,有什么用?
Spring Boot提供了多项组件的健康检查,有利于监控各组件运行状况,但是有时开发者因此会启动不成功,报错等,需要合理配置。
2.Spring Boot项目中都有哪些检查,如何配置相关检查:
2.1首先健康检查引入的包是
<dependency>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-actuator</artifactid>
</dependency>
2.2相关健康检查相关Indicator
CassandraHealthIndicator 检查Cassandra是否可用
DiskSpaceHealthIndicator 检查磁盘空间是否不足
DataSourceHealthIndicator 检查能否从DataSource获取链接
ElasticsearchHealthIndicator 检查Elasticsearch cluste是否可用
JmsHealthIndicator 检查JMS broker是否可用
MailHealthIndicator 检查mail server是否可用
MongoHealthIndicator 检查Mongo database是否可用
RabbitHealthIndicator 检查Rabbit server是否可用
RedisHealthIndicator 检查Redis server是否可用
SolrHealthIndicator 检查Solr server是否可用
可以看到,有各项外部服务的检查,具体的请浏览官方文档,这里不再赘余
2.3如何关闭/开启健康检查
application.properties里显式设定
//如禁止es的健康检查如下,默认均为开启状态
management.health.elasticsearch.enabled=false
也可以使用*全部禁止
management.health.*.enabled=false