RestController的配置将YAML反序列化为pojo上载为原始主体?

问题描述 投票:1回答:1

在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"));
    }
}
spring spring-mvc spring-boot spring-webflux
1个回答
0
投票

我发现如果你只是注册YAML HttpMessageConverter作为bean webflux会自动使用它。

© www.soinside.com 2019 - 2024. All rights reserved.