diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/BasicErrorControllerSpecialIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/BasicErrorControllerSpecialIntegrationTests.java index dcdbfa5369d..7cabdf463d6 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/BasicErrorControllerSpecialIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/BasicErrorControllerSpecialIntegrationTests.java @@ -20,7 +20,6 @@ import org.junit.After; import org.junit.Test; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; @@ -78,8 +77,7 @@ public class BasicErrorControllerSpecialIntegrationTests { } @Configuration - // TODO: fix this so it doesn't need to be excluded - @EnableAutoConfiguration(exclude = ServerPropertiesAutoConfiguration.class) + @EnableAutoConfiguration protected static class ParentConfiguration { } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java index 3625643194e..f84c200b29a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java @@ -19,6 +19,8 @@ package org.springframework.boot.autoconfigure.web; import org.springframework.beans.BeansException; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -38,13 +40,14 @@ import org.springframework.util.StringUtils; */ @Configuration @EnableConfigurationProperties +@ConditionalOnWebApplication public class ServerPropertiesAutoConfiguration implements ApplicationContextAware, EmbeddedServletContainerCustomizer { private ApplicationContext applicationContext; @Bean(name = "org.springframework.boot.autoconfigure.web.ServerProperties") - @ConditionalOnMissingBean + @ConditionalOnMissingBean(search = SearchStrategy.CURRENT) public ServerProperties serverProperties() { return new ServerProperties(); }