diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webflux/ReactiveWebServerAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webflux/ReactiveWebServerAutoConfiguration.java index 3198b34aeea..dcac771d13e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webflux/ReactiveWebServerAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webflux/ReactiveWebServerAutoConfiguration.java @@ -84,9 +84,11 @@ public class ReactiveWebServerAutoConfiguration { } if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType( ReactiveWebServerCustomizerBeanPostProcessor.class, true, false))) { + RootBeanDefinition beanDefinition = new RootBeanDefinition( + ReactiveWebServerCustomizerBeanPostProcessor.class); + beanDefinition.setSynthetic(true); registry.registerBeanDefinition( - "reactiveWebServerCustomizerBeanPostProcessor", - new RootBeanDefinition(ReactiveWebServerCustomizerBeanPostProcessor.class)); + "reactiveWebServerCustomizerBeanPostProcessor", beanDefinition); } } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ReactiveWebServerCustomizerBeanPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ReactiveWebServerCustomizerBeanPostProcessor.java index 36693a8066a..4992640cc87 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ReactiveWebServerCustomizerBeanPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ReactiveWebServerCustomizerBeanPostProcessor.java @@ -22,29 +22,30 @@ import java.util.Collections; import java.util.List; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; import org.springframework.core.annotation.AnnotationAwareOrderComparator; /** * {@link BeanPostProcessor} that applies all {@link ReactiveWebServerCustomizer}s * from the bean factory to {@link ConfigurableReactiveWebServer} beans. * - * * @author Brian Clozel + * @author Stephane Nicoll + * @since 2.0.0 */ public class ReactiveWebServerCustomizerBeanPostProcessor - implements BeanPostProcessor, ApplicationContextAware { + implements BeanPostProcessor, BeanFactoryAware { - private ApplicationContext applicationContext; + private ListableBeanFactory beanFactory; private List customizers; @Override - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { - this.applicationContext = applicationContext; + public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + this.beanFactory = (ListableBeanFactory) beanFactory; } @Override @@ -73,7 +74,7 @@ public class ReactiveWebServerCustomizerBeanPostProcessor if (this.customizers == null) { // Look up does not include the parent context this.customizers = new ArrayList( - this.applicationContext + this.beanFactory .getBeansOfType(ReactiveWebServerCustomizer.class, false, false) .values());