bob
bob

Reputation: 47

SpringMVC global setting for ignoring unknown properties during deserialization

Spring Boot sets "spring.jackson.deserialization.fail-on-unknown-properties=false" by default. I have a library that works fine in Spring Boot, but when used in an existing SpringMVC app it throws "Unrecognized field, not marked as ignorable". Is there some comparable global setting for SpringMVC I can set in the config or otherwise?

edit: spring webmvc version 3.2.15.RELEASE

Upvotes: 1

Views: 1659

Answers (2)

ray
ray

Reputation: 1680

You can follow two method that I have mention in this answer. If I'm not wrong either one will work for you. (But method 1 won't work if your clinet class does not have a no-arg default constructor)

Upvotes: 1

Shai Givati
Shai Givati

Reputation: 1156

You can annotate the mapped classes with

@JsonIgnoreProperties(ignoreUnknown = true)

or create add the following configuration to the ObjectMapper as follows:

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

Upvotes: 1

Related Questions