类 WebFluxConfigurationSupport
- java.lang.Object
- org.springframework.web.reactive.config.WebFluxConfigurationSupport
- 所有已实现的接口:
Aware
,ApplicationContextAware
public class WebFluxConfigurationSupport extends Object implements ApplicationContextAware
The main class for Spring WebFlux configuration.Import directly or extend and override protected methods to customize.
- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Brian Clozel
构造器概要
构造器 构造器 说明 WebFluxConfigurationSupport()
方法概要
构造器详细资料
WebFluxConfigurationSupport
public WebFluxConfigurationSupport()
方法详细资料
setApplicationContext
public void setApplicationContext(@Nullable ApplicationContext applicationContext)
从接口复制的说明:ApplicationContextAware
Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- 指定者:
setApplicationContext
在接口中ApplicationContextAware
- 参数:
applicationContext
- the ApplicationContext object to be used by this object- 另请参阅:
BeanInitializationException
getApplicationContext
@Nullable public final ApplicationContext getApplicationContext()
webHandler
@Bean public DispatcherHandler webHandler()
responseStatusExceptionHandler
@Bean @Order(0) public WebExceptionHandler responseStatusExceptionHandler()
requestMappingHandlerMapping
@Bean public RequestMappingHandlerMapping requestMappingHandlerMapping(@Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver)
createRequestMappingHandlerMapping
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping()
Override to plug a sub-class ofRequestMappingHandlerMapping
.
webFluxContentTypeResolver
@Bean public RequestedContentTypeResolver webFluxContentTypeResolver()
configureContentTypeResolver
protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder)
Override to configure how the requested content type is resolved.
getCorsConfigurations
protected final Map<String,CorsConfiguration> getCorsConfigurations()
Callback for building the global CORS configuration. This method is final. UseaddCorsMappings(CorsRegistry)
to customize the CORS conifg.
addCorsMappings
protected void addCorsMappings(CorsRegistry registry)
Override this method to configure cross origin requests processing.- 另请参阅:
CorsRegistry
getPathMatchConfigurer
protected final PathMatchConfigurer getPathMatchConfigurer()
Callback for building thePathMatchConfigurer
. This method is final, useconfigurePathMatching(org.springframework.web.reactive.config.PathMatchConfigurer)
to customize path matching.
configurePathMatching
public void configurePathMatching(PathMatchConfigurer configurer)
Override to configure path matching options.
routerFunctionMapping
@Bean public RouterFunctionMapping routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer)
createRouterFunctionMapping
protected RouterFunctionMapping createRouterFunctionMapping()
Override to plug a sub-class ofRouterFunctionMapping
.
resourceHandlerMapping
@Bean public HandlerMapping resourceHandlerMapping(ResourceUrlProvider resourceUrlProvider)
Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers. To configure resource handling, overrideaddResourceHandlers(org.springframework.web.reactive.config.ResourceHandlerRegistry)
.
resourceUrlProvider
@Bean public ResourceUrlProvider resourceUrlProvider()
addResourceHandlers
protected void addResourceHandlers(ResourceHandlerRegistry registry)
Override this method to add resource handlers for serving static resources.
requestMappingHandlerAdapter
@Bean public RequestMappingHandlerAdapter requestMappingHandlerAdapter(@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, @Qualifier("webFluxConversionService") FormattingConversionService conversionService, @Qualifier("webFluxValidator") Validator validator)
createRequestMappingHandlerAdapter
protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter()
Override to plug a sub-class ofRequestMappingHandlerAdapter
.
configureArgumentResolvers
protected void configureArgumentResolvers(ArgumentResolverConfigurer configurer)
Configure resolvers for custom controller method arguments.
serverCodecConfigurer
@Bean public ServerCodecConfigurer serverCodecConfigurer()
Return the configurer for HTTP message readers and writers.Use
configureHttpMessageCodecs(ServerCodecConfigurer)
to configure the readers and writers.
createLocaleContextResolver
protected LocaleContextResolver createLocaleContextResolver()
Override to plug a sub-class ofLocaleContextResolver
.
localeContextResolver
@Bean public LocaleContextResolver localeContextResolver()
configureHttpMessageCodecs
protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer)
Override to configure the HTTP message readers and writers to use.
getConfigurableWebBindingInitializer
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer(FormattingConversionService webFluxConversionService, Validator webFluxValidator)
Return theConfigurableWebBindingInitializer
to use for initializing allWebDataBinder
instances.
webFluxConversionService
@Bean public FormattingConversionService webFluxConversionService()
Return aFormattingConversionService
for use with annotated controllers.See
addFormatters(org.springframework.format.FormatterRegistry)
as an alternative to overriding this method.
addFormatters
protected void addFormatters(FormatterRegistry registry)
Override this method to add customConverter
and/orFormatter
delegates to the commonFormattingConversionService
.
webFluxAdapterRegistry
@Bean public ReactiveAdapterRegistry webFluxAdapterRegistry()
Return aReactiveAdapterRegistry
to adapting reactive types.
webFluxValidator
@Bean public Validator webFluxValidator()
Return a globalValidator
instance for example for validating@RequestBody
method arguments.Delegates to
getValidator()
first. If that returnsnull
checks the classpath for the presence of a JSR-303 implementations before creating aOptionalValidatorFactoryBean
. If a JSR-303 implementation is not available, a "no-op"Validator
is returned.
getValidator
@Nullable protected Validator getValidator()
Override this method to provide a customValidator
.
getMessageCodesResolver
@Nullable protected MessageCodesResolver getMessageCodesResolver()
Override this method to provide a customMessageCodesResolver
.
handlerFunctionAdapter
@Bean public HandlerFunctionAdapter handlerFunctionAdapter()
simpleHandlerAdapter
@Bean public SimpleHandlerAdapter simpleHandlerAdapter()
responseEntityResultHandler
@Bean public ResponseEntityResultHandler responseEntityResultHandler(@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver)
responseBodyResultHandler
@Bean public ResponseBodyResultHandler responseBodyResultHandler(@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver)
viewResolutionResultHandler
@Bean public ViewResolutionResultHandler viewResolutionResultHandler(@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver)
serverResponseResultHandler
@Bean public ServerResponseResultHandler serverResponseResultHandler(ServerCodecConfigurer serverCodecConfigurer)
getViewResolverRegistry
protected final ViewResolverRegistry getViewResolverRegistry()
Callback for building theViewResolverRegistry
. This method is final, useconfigureViewResolvers(org.springframework.web.reactive.config.ViewResolverRegistry)
to customize view resolvers.
configureViewResolvers
protected void configureViewResolvers(ViewResolverRegistry registry)
Configure view resolution for supporting template engines.- 另请参阅:
ViewResolverRegistry