Move JDBC health auto-configuration into spring-boot-jdbc

See gh-46085
This commit is contained in:
Andy Wilkinson 2025-05-16 19:20:57 +01:00
parent ce51459399
commit e2c7b42ee0
10 changed files with 17 additions and 19 deletions

View File

@ -57,7 +57,6 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-http-codec"))
optional(project(":spring-boot-project:spring-boot-integration"))
optional(project(":spring-boot-project:spring-boot-jackson"))
optional(project(":spring-boot-project:spring-boot-jdbc"))
optional(project(":spring-boot-project:spring-boot-jersey"))
optional(project(":spring-boot-project:spring-boot-jetty"))
optional(project(":spring-boot-project:spring-boot-jsonb"))
@ -159,7 +158,6 @@ dependencies {
optional("org.mongodb:mongodb-driver-sync")
optional("org.neo4j.driver:neo4j-java-driver")
optional("org.quartz-scheduler:quartz")
optional("org.springframework:spring-jdbc")
optional("org.springframework:spring-messaging")
optional("org.springframework:spring-webflux")
optional("org.springframework:spring-webmvc")

View File

@ -41,12 +41,6 @@
"level": "error"
}
},
{
"name": "management.health.db.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable database health check.",
"defaultValue": true
},
{
"name": "management.health.defaults.enabled",
"type": "java.lang.Boolean",

View File

@ -16,7 +16,6 @@ org.springframework.boot.actuate.autoconfigure.endpoint.jackson.JacksonEndpointA
org.springframework.boot.actuate.autoconfigure.endpoint.jmx.JmxEndpointAutoConfiguration
org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration
org.springframework.boot.actuate.autoconfigure.integration.IntegrationGraphEndpointAutoConfiguration
org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.jms.JmsHealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.ldap.LdapHealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.liquibase.LiquibaseEndpointAutoConfiguration

View File

@ -34,7 +34,7 @@ dependencies {
implementation(project(":spring-boot-project:spring-boot-tx"))
optional(project(":spring-boot-project:spring-boot-actuator"))
optional(project(":spring-boot-project:spring-boot-actuator-autoconfigure"))
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
optional("com.h2database:h2")
optional("com.mchange:c3p0")

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.jdbc;
package org.springframework.boot.jdbc.actuate.health.autoconfigure;
import java.sql.SQLException;
import java.util.Collection;
@ -61,10 +61,10 @@ import org.springframework.util.Assert;
* @author Arthur Kalimullin
* @author Julio Gomez
* @author Safeer Ansari
* @since 2.0.0
* @since 4.0.0
*/
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
@ConditionalOnClass({ JdbcTemplate.class, AbstractRoutingDataSource.class, DataSourceHealthIndicator.class })
@ConditionalOnClass({ JdbcTemplate.class, AbstractRoutingDataSource.class, ConditionalOnEnabledHealthIndicator.class })
@ConditionalOnBean(DataSource.class)
@ConditionalOnEnabledHealthIndicator("db")
@EnableConfigurationProperties(DataSourceHealthIndicatorProperties.class)

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.jdbc;
package org.springframework.boot.jdbc.actuate.health.autoconfigure;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.actuate.health.DataSourceHealthIndicator;
@ -23,7 +23,7 @@ import org.springframework.boot.jdbc.actuate.health.DataSourceHealthIndicator;
* External configuration properties for {@link DataSourceHealthIndicator}.
*
* @author Julio Gomez
* @since 2.4.0
* @since 4.0.0
*/
@ConfigurationProperties("management.health.db")
public class DataSourceHealthIndicatorProperties {

View File

@ -15,6 +15,6 @@
*/
/**
* Auto-configuration for actuator JDBC concerns.
* Auto-configuration for JDBC health integration.
*/
package org.springframework.boot.actuate.autoconfigure.jdbc;
package org.springframework.boot.jdbc.actuate.health.autoconfigure;

View File

@ -1,5 +1,11 @@
{
"properties": [
{
"name": "management.health.db.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable database health check.",
"defaultValue": true
},
{
"name": "spring.datasource.continue-on-error",
"type": "java.lang.Boolean",

View File

@ -1,3 +1,4 @@
org.springframework.boot.jdbc.actuate.health.autoconfigure.DataSourceHealthContributorAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.jdbc;
package org.springframework.boot.jdbc.actuate.health.autoconfigure;
import java.sql.SQLException;
import java.util.HashMap;
@ -30,7 +30,6 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration.RoutingDataSourceHealthContributor;
import org.springframework.boot.actuate.health.CompositeHealthContributor;
import org.springframework.boot.actuate.health.NamedContributor;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -38,6 +37,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.jdbc.actuate.health.DataSourceHealthIndicator;
import org.springframework.boot.jdbc.actuate.health.autoconfigure.DataSourceHealthContributorAutoConfiguration.RoutingDataSourceHealthContributor;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
import org.springframework.boot.jdbc.metadata.autoconfigure.DataSourcePoolMetadataProvidersConfiguration;