我正在使用具有配置反序列化功能的杰克逊ObjectMapper的单个实例,因为我的应用程序中的未知属性为 false ,因此失败。
有时不正确,这是行不通的。
属性名称定义冲突/含糊(隐式名称'indskr_indskr_customeraddress_v2id'):找到了多个显式名称:[customeraddressid_v2_id,indskr_indskr_customeraddress_v2id],但也隐含了存取器:[field com.indegene.bulkdata.dto.CustomerAddress#indskr_indskr_customeraddress_v2id] [visible = true,ignore = false,explicitName = false]
例外仅在dev env中出现,无法在我的本地系统中复制。这是零星的问题。
mObjectMapper = new ObjectMapper();
mObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
private String indskr_indskr_customeraddress_v2id;
@JsonGetter("indskr_indskr_customeraddress_v2id")
public String getIndskr_indskr_customeraddress_v2id() {
return indskr_indskr_customeraddress_v2id;
}
@JsonSetter("customeraddressid_v2_id")
public void setIndskr_indskr_customeraddress_v2id(String indskr_indskr_customeraddress_v2id) {
this.indskr_indskr_customeraddress_v2id = indskr_indskr_customeraddress_v2id;
}
stacktrace
java.lang.IllegalStateException: Conflicting/ambiguous property name definitions (implicit name 'indskr_indskr_customeraddress_v2id'): found multiple explicit names: [customeraddressid_v2_id, indskr_indskr_customeraddress_v2id], but also implicit accessor: [field com.indegene.bulkdata.dto.CustomerAddress#indskr_indskr_customeraddress_v2id][visible=true,ignore=false,explicitName=false]
at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder._explode(POJOPropertyBuilder.java:1062) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.explode(POJOPropertyBuilder.java:1041) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._renameProperties(POJOPropertiesCollector.java:798) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:324) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getPropertyMap(POJOPropertiesCollector.java:287) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getProperties(POJOPropertiesCollector.java:170) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.BasicBeanDescription._properties(BasicBeanDescription.java:164) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findProperties(BasicBeanDescription.java:239) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._findCreatorsFromProperties(BasicDeserializerFactory.java:346) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._constructDefaultValueInstantiator(BasicDeserializerFactory.java:330) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findValueInstantiator(BasicDeserializerFactory.java:255) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:214) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:137) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:411) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:444) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:183) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:27) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:682) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:482) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:4178) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3997) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3011) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.indegene.bulkdata.service.impl.ContactServiceImpl.getCustomerAddress(ContactServiceImpl.java:490) ~[classes!/:na]
at com.indegene.bulkdata.service.impl.ContactServiceImpl.lambda$getCustomerAddressCompletableFuture$7(ContactServiceImpl.java:257) ~[classes!/:na]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) ~[na:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_212]
预期:我不会出现错误
实际:有时会抛出错误
答案 0 :(得分:1)
检查此部分错误:
找到多个显式名称:[customeraddressid_v2_id,indskr_indskr_customeraddress_v2id],但也隐式访问:[field com.indegene.bulkdata.dto.CustomerAddress#indskr_indskr_customeraddress_v2id]
您会注意到有两个显式声明,因此您可能在其他地方与@JsonProperty
冲突的地方有@JsonSetter
注释。删除多余的注释应该可以解决。