Spring Boot Actuator Health Indicator

后端 未结 3 911
误落风尘
误落风尘 2021-01-14 02:04

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 f

3条回答
  •  死守一世寂寞
    2021-01-14 02:45

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

    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");
    }
    

提交回复
热议问题