feign 序列化_Spring Cloud Feign 配置 FastJson

如今,越来越多的Spring MVC项目都选择使用FastJson做为Json解析框架,并且都会添加类似如下配置以支持FastJson:

@Configuration

public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

@Override

public void configureMessageConverters(

List> converters) {

FastJsonHttpMessageConverter converter =

new FastJsonHttpMessageConverter();

List supportedMediaTypes = new ArrayList();

MediaType mediaTypeJson =

MediaType.valueOf(MediaType.APPLICATION_JSON_UTF8_VALUE);

supportedMediaTypes.add(mediaTypeJson);

converter.setSupportedMediaTypes(supportedMediaTypes);

FastJsonConfig config = new FastJsonConfig();

config.getSerializeConfig()

.put(Json.class, new SwaggerJsonSerializer());

config.setSerializerFeatures(

SerializerFeature.DisableCircularReferenceDetect);

converter.setFas

你可能感兴趣的:(feign,序列化)