SpringCloud:feign默认jackson解析'yyyy-MM-ddTHH:mm:ssZ'时间格式报错
Feign默认的使用jackson解析,所以时间传值时会报错,时间格式错误
解决办法:
修改feign解析方式为fastjson方式:
@Configuration public class CxfConfig{ @Bean public Encoder feignEncoder(){ return new SpringEncoder(feignHttpMessageConverter()); } @Bean public Decoder feignDecoder(){ return new SpringDecoder(feignHttpMessageConverter()); } /** *feign和Springboot使用的都是jackson,可以都修改为fastjson解析方式 */ private ObjectFactory<HttpMessageConverters> feignHttpMessageConverter(){ final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(this.getFastJsonConverter()); return () -> httpMessageConverters; } private FastJsonHttpMessageConverter getFastJsonConverter(){ FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); List<MediaType> supportedMediaTypes = ArrayList<>(); MediaType mediaTypeJson = MediaType.valueOf(MediaType.APPLICATION_JSON_UTF8_VALUE); supportedMediaTypes.add(mediaTypeJson); FastJsonConfig config = new FastJsonConfig(); config.getSerializeConfig().put(JSON.class,new SwaggerJsonSerializer()); config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect); converter.setFastJsonConfig(config); return converter; } }
-----------------------------------
作者:怒吼的萝卜
链接:http://www.cnblogs.com/nhdlb/
-----------------------------------