-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
WebFluxAutoConfiguration
injects ResourceHandlerRegistrationCustomizer
using ObjectProvider.getIfAvailable()
:
Line 181 in 8964203
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizer.getIfAvailable(); |
When multiple ResourceHandlerRegistrationCustomizer
are in the context, this causes the WebFlux auto config to use an arbitrary one of them, instead of all of them.
In my case, webjars-locator-light
joined my classpath due to a version update of another library. Due to this, @ConditionalOnEnabledResourceChain
started matching, causing Boot to define its own customizer bean here:
Lines 351 to 361 in 8964203
@Configuration(proxyBeanMethods = false) | |
@ConditionalOnEnabledResourceChain | |
static class ResourceChainCustomizerConfiguration { | |
@Bean | |
ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer( | |
WebProperties webProperties) { | |
return new ResourceChainResourceHandlerRegistrationCustomizer(webProperties.getResources()); | |
} | |
} |
This instance is the one that ends up being used, and my own is ignored.
I propose to allow an arbitrary number of customizer beans to work here, similar to the various other customizer callback interfaces used in Spring Boot's auto-configuration.
I'm currently working around this issue by marking my bean as @Primary
.