弹簧启动执行器运行状况指示器 [英] Spring Boot Actuator Health Indicator

查看:78
本文介绍了弹簧启动执行器运行状况指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们现在已经将Spring Boot用于多个项目,我们使用的是最新版本1.2.3.我们正在合并执行器.到目前为止,一切工作正常,只不过我们发现/health指示器[默认]显示服务已关闭.这不是真的.这些服务是使用数据源实现的.它可以调用其他SOAP或Rest服务.卫生服务在寻找什么来衡量服务是否宕机?

We have been using Spring Boot for several projects now, We are using the latest version 1.2.3. We are incorporating Actuator. So far things are working well except we are finding that the /health indicator [default] is showing that the service is down. This is not true. These services are that implement with datasources. It may call other SOAP or Rest services. What is the health service looking at to measure whether a service is down?

推荐答案

#derFuerst 所述,DataSourceHealthIndicator具有用于查询数据库是否已启动的默认查询.

As #derFuerst said the DataSourceHealthIndicator has the default query to check whether the DB is up or not.

如果要使用此正确的特定于供应商的查询,则应在配置类中编写自己的运行状况指示器,例如在 Oracle 数据源的情况下:

If you want to use this the proper vendor specific query you should write your own health indicator in your configuration class, like this in case of Oracle data source:

@Autowired(required = false)
private DataSource dataSource;

@Bean
@Primary
public DataSourceHealthIndicator dataSourceHealthIndicator() {
    return new DataSourceHealthIndicator(dataSource, "SELECT 1 FROM DUAL");
}

这篇关于弹簧启动执行器运行状况指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆