WebFluxConfigurer is the Spring WebFlux callback interface for customizing the framework's default configuration. You implement it in a @Configuration class and override only the methods you need, for example to add CORS mappings, register formatters, change codecs, add argument resolvers or serve static resources.
It is the reactive counterpart of WebMvcConfigurer. All methods are default no-ops, so a class implementing it changes nothing until it overrides something.
Spring WebFlux ships with sensible defaults for annotated controllers: JSON codecs, content negotiation, formatters and a validator. WebFluxConfigurer is the extension point for adjusting those defaults without replacing the whole setup. The interface lives in org.springframework.web.reactive.config.
With Spring Boot, WebFlux is auto-configured and your WebFluxConfigurer beans are picked up automatically. That is the intended way to customize behaviour while keeping Boot's defaults.
| Method | Purpose |
|---|---|
addCorsMappings | Define CORS rules for path patterns |
configureHttpMessageCodecs | Customize or register codecs, such as Jackson settings and size limits |
addFormatters | Register Converter and Formatter instances |
configureArgumentResolvers | Add custom controller method argument resolvers |
configureContentTypeResolver | Control content negotiation |
configurePathMatching | Change path matching options, such as path prefixes for controllers |
addResourceHandlers | Serve static resources |
configureViewResolvers | Configure view resolution for template engines |
getValidator | Provide a custom Validator |
configureBlockingExecution | Choose the executor for blocking controller methods (Spring 6.1 and later) |
Interceptors are not in this list. WebFlux has no HandlerInterceptor; use a WebFilter for cross-cutting request logic instead.
The first method allows a specific origin to call /api/** from a browser. The second raises the limit of in-memory request body buffering to 1 MB. If you use Spring Security, CORS must also be enabled there, because the security filter chain runs before the MVC-style mapping.
A Converter turns request strings into your types, for example a path variable into a value object:
With that registered, a controller can declare @PathVariable ProductId id or a custom Tenant parameter, and the framework resolves it before invoking the method.
The second override prefixes every @RestController route with /api, which avoids repeating the prefix in each controller.
@EnableWebFlux imports the default WebFlux configuration and, in a Boot application, disables Boot's WebFluxAutoConfiguration. You lose the Boot defaults for Jackson, static resources and error handling. Use @EnableWebFlux only in a non-Boot application. In Boot, implement WebFluxConfigurer and let auto-configuration do the rest.
Also note that WebFluxConfigurer applies to annotated controllers. Functional routes declared with RouterFunction use HandlerStrategies and WebFilter for customization instead.
They have the same role and similar methods, but they belong to different web stacks. Use WebFluxConfigurer for WebFlux and WebMvcConfigurer for servlet-based Spring MVC.
Yes. Spring combines all of them, applying each one's customizations.
Register a WebFilter bean, since WebFlux has no interceptor concept.
Not for simple cases. Properties such as spring.codec.max-in-memory-size cover common options; use the interface when a property does not exist.
WebFluxConfigurer customizes the default WebFlux setup through hooks for CORS, codecs, formatters, argument resolvers, path matching and resources. Implement it in a @Configuration class, override only what you need, avoid @EnableWebFlux in Spring Boot, and use WebFilter for request interception.