在spring 5 webflux中,以下spring mvc代码的等效配置是什么?如何在webflux中添加多个转换器?
@Configuration
public class YamlConfiguration extends WebMvcConfigurerAdapter {
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new YamlJackson2HttpMessageConverter());
}
}
final class YamlJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter {
YamlJackson2HttpMessageConverter() {
super(new YAMLMapper(), MediaType.parseMediaType("application/x-yaml"));
}
}
我发现如果你只是注册YAML HttpMessageConverter
作为bean webflux会自动使用它。