diff --git a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/web/servlet/WebMvcMetricsConfiguration.java b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/web/servlet/WebMvcMetricsConfiguration.java index cc0a1f783b..1adc605bce 100644 --- a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/web/servlet/WebMvcMetricsConfiguration.java +++ b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/web/servlet/WebMvcMetricsConfiguration.java @@ -23,6 +23,7 @@ import io.micrometer.spring.web.servlet.WebMvcTagsProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -37,6 +38,7 @@ */ @Configuration @ConditionalOnClass(DispatcherServlet.class) +@ConditionalOnWebApplication @EnableConfigurationProperties(MetricsProperties.class) public class WebMvcMetricsConfiguration {