UnrecognizedPropertyException异常问题解决

试管婴儿成功与代孕

发布时间:2021-10-18 00:08:26

试管婴儿成功与代孕【中泰好孕】以资深医生资源为核心,成熟的代孕生殖流程体系集特色服务于一体,提供一站式健康生育服务,多年经验 行业领跑者,是您放心的选择.



在SpringCloud架构中使用Feign发起远程调用报出如下异常 :


feign.codec.Decodeexception: Error while extracting response for type [xxx.Result<xxx.XXXBO>] and content type [application/Json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unrecognized field "objectInfo" (class xxDTO), not marked as ignorable; nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "objectInfo" (class xxDTO), not marked as ignorable (28 known properties: "xxx", xxx", ..., "xxx"]) at [Source: (PushbackInputStream); line: 1, column: 3092] ( through reference chain: xx.Result["data"]->xxBO["courseList"]->xx.ListData["list"]->java.util.ArrayList[2]->xxDTO["objectInfo"])

解决办法 :


1.重写WebMvcConfigurerAdapter的configureMessageConverters方法


ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.readValue(json,cls);

2.Bean上加入注解声明


@JsonIgnoreProperties(ignoreUnknown = true)c103ead7

返回顶部