Consider the following example:
@JsonIgnoreProperties(ignoreUnknown = true)
class ModelA {
private ModelB modelB;
}
ModelB
introduces two overloaded methods such as setProperty(String)
and setProperty(Object)
. This confuses Jackson's ObjectMapper
complaining about "confliciting setter definitions":
Caused by: java.lang.IllegalArgumentException:
Conflicting setter definitions for property "property": ModelB#setProperty(1 params) vs ModelB#setProperty(1 params)
I'm aware that if I can use inheritance then I can use @JsonIgnore
as in proposed in this answer. I'm also aware that a bottom-line solution would be to develop a custom Jackson deserializer (although very complex in my case). But, I'd like to know if there is a workaround for this if I'm restricted to use composition?