Spring Webflux编解码器:可以在全局默认编解码器列表中添加自定义编解码器吗?



我已经展示了如何分别使用codec-configurerweb-client属性向webflux:inbound-gatewaywebflux:outbound-gateway声明添加自定义编解码器。如何添加HttpMessageWriter<>To webflux outbound-gateway

是否有一种方法(甚至可能是一种简单的方法)将自定义编解码器添加到默认编解码器列表中,从而避免在端点中声明这些编解码器?

参见CodecConfigurerFactory。您可以使用CodecConfigurer.properties文件为这些编解码器指定自定义策略:

# Default CodecConfigurer implementation classes for static Client/ServerCodecConfigurer.create() calls.
# Not meant to be customized by application developers; simply instantiate custom impl classes instead.
org.springframework.http.codec.ClientCodecConfigurer=org.springframework.http.codec.support.DefaultClientCodecConfigurer
org.springframework.http.codec.ServerCodecConfigurer=org.springframework.http.codec.support.DefaultServerCodecConfigurer

最新更新