diff --git a/spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json index c9a68e3651..b2320acd6b 100644 --- a/spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -85,6 +85,18 @@ "type": "java.util.Map", "description": "Arbitrary properties to add to the info endpoint." }, + { + "name": "management.health.cassandra.enabled", + "type": "java.lang.Boolean", + "description": "Enable cassandra health check.", + "defaultValue": true + }, + { + "name": "management.health.couchbase.enabled", + "type": "java.lang.Boolean", + "description": "Enable couchbase health check.", + "defaultValue": true + }, { "name": "management.health.db.enabled", "type": "java.lang.Boolean", diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java index 937ab513a1..c678ba66af 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java @@ -457,6 +457,21 @@ public class HealthIndicatorAutoConfigurationTests { .isEqualTo(CassandraHealthIndicator.class); } + @Test + public void notCassandraHealthIndicator() throws Exception { + EnvironmentTestUtils.addEnvironment(this.context, + "management.health.diskspace.enabled:false", + "management.health.cassandra.enabled:false"); + this.context.register(CassandraConfiguration.class, + ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); + this.context.refresh(); + Map beans = this.context + .getBeansOfType(HealthIndicator.class); + assertThat(beans).hasSize(1); + assertThat(beans.values().iterator().next().getClass()) + .isEqualTo(ApplicationHealthIndicator.class); + } + @Test public void couchbaseHealthIndicator() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, @@ -471,6 +486,21 @@ public class HealthIndicatorAutoConfigurationTests { .isEqualTo(CouchbaseHealthIndicator.class); } + @Test + public void notCouchbaseHealthIndicator() throws Exception { + EnvironmentTestUtils.addEnvironment(this.context, + "management.health.diskspace.enabled:false", + "management.health.couchbase.enabled:false"); + this.context.register(CouchbaseConfiguration.class, + ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); + this.context.refresh(); + Map beans = this.context + .getBeansOfType(HealthIndicator.class); + assertThat(beans.size()).isEqualTo(1); + assertThat(beans.values().iterator().next().getClass()) + .isEqualTo(ApplicationHealthIndicator.class); + } + @Configuration @EnableConfigurationProperties protected static class DataSourceConfig { diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 6f9065ccde..0d62c5472c 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1067,6 +1067,8 @@ content into your application; rather pick only the properties that you need. # HEALTH INDICATORS (previously health.*) management.health.db.enabled=true # Enable database health check. + management.health.cassandra.enabled=true # Enable cassandra health check. + management.health.couchbase.enabled=true # Enable couchbase health check. management.health.defaults.enabled=true # Enable default health indicators. management.health.diskspace.enabled=true # Enable disk space health check. management.health.diskspace.path= # Path used to compute the available disk space.