Skip to content

Adding @EnableAutoConfiguration on an auto-configuration breaks ordering #14687

@bcalmac

Description

@bcalmac

The /actuator/health endpoint for our spring-boot application does not include the 'db' indicator and I tracked it down to DataSourceHealthIndicatorAutoConfiguration not seeing the dataSouce bean.

I have also attached the full log, but in this small snippet you can see that Liquibase and Mybatis see the Hikari dataSource just fine.

   DataSourceConfiguration.Hikari matched:
      - @ConditionalOnClass found required class 'com.zaxxer.hikari.HikariDataSource'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
      - @ConditionalOnProperty (spring.datasource.type=com.zaxxer.hikari.HikariDataSource) matched (OnPropertyCondition)
      - @ConditionalOnMissingBean (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans (OnBeanCondition)
...
   LiquibaseAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'liquibase.integration.spring.SpringLiquibase', 'liquibase.change.DatabaseChange'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
      - @ConditionalOnProperty (spring.liquibase.enabled) matched (OnPropertyCondition)
      - @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) found bean 'dataSource' (OnBeanCondition)
...
   MybatisAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'org.apache.ibatis.session.SqlSessionFactory', 'org.mybatis.spring.SqlSessionFactoryBean'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
      - @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) found bean 'dataSource' (OnBeanCondition)
...
   DataSourceHealthIndicatorAutoConfiguration:
      Did not match:
         - @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans of type javax.sql.DataSource (OnBeanCondition)
      Matched:
         - @ConditionalOnClass found required classes 'org.springframework.jdbc.core.JdbcTemplate', 'org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
         - @ConditionalOnEnabledHealthIndicator management.health.defaults.enabled is considered true (OnEnabledHealthIndicatorCondition)

The data source configuration is standard:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/ccp_product?currentSchema=product
    username: product
    password: ********
    driver-class-name: org.postgresql.Driver

Spring Boot Version: 2.0.5.RELEASE

This is a regression, the 'db' health indicator works fine in the version that I'm upgrading from, 1.5.10.RELEASE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions