spring-framework / org.springframework.web.reactive.config

Package org.springframework.web.reactive.config

Types

CorsRegistration

open class CorsRegistration

Assists with the creation of a CorsConfiguration instance mapped to a path pattern. By default all origins, headers, and credentials for GET, HEAD, and POST requests are allowed while the max age is set to 30 minutes.

ResourceHandlerRegistration

open class ResourceHandlerRegistration

Assist with creating and configuring a static resources handler.

UrlBasedViewResolverRegistration

open class UrlBasedViewResolverRegistration

Assist with configuring properties of a UrlBasedViewResolver.

WebFluxConfigurationSupport

open class WebFluxConfigurationSupport : ApplicationContextAware

The main class for Spring WebFlux configuration.

Import directly or extend and override protected methods to customize.

WebFluxConfigurerComposite

open class WebFluxConfigurerComposite : WebFluxConfigurer

A WebFluxConfigurer that delegates to one or more others.

Annotations

EnableWebFlux

class EnableWebFlux

Adding this annotation to an @Configuration class imports the Spring Web Reactive configuration from WebFluxConfigurationSupport, e.g.:

 @Configuration @EnableWebFlux @ComponentScan(basePackageClasses = MyConfiguration.class) public class MyConfiguration { } 

To customize the imported configuration implement WebFluxConfigurer and override individual methods as shown below:

 @Configuration @EnableWebFlux @ComponentScan(basePackageClasses = MyConfiguration.class) public class MyConfiguration implements WebFluxConfigurer { @Override public void addFormatters(FormatterRegistry formatterRegistry) { formatterRegistry.addConverter(new MyConverter()); } @Override public void configureMessageWriters(List<HttpMessageWriter<?>> messageWriters) { messageWriters.add(new MyHttpMessageWriter()); } } 

Note: only one @Configuration class may have the @EnableWebFlux annotation to import the Spring WebFlux configuration. There can however be multiple @Configuration classes implementing WebFluxConfigurer in order to customize the provided configuration.

If WebFluxConfigurer does not expose some more advanced setting that needs to be configured consider removing the @EnableWebFlux annotation and extending directly from WebFluxConfigurationSupport or DelegatingWebFluxConfiguration if you still want to allow WebFluxConfigurer instances to customize the configuration.