I'm trying to deserialize some JSON with Jackson in Spring. I have configured it to use a custom MappingJackson2HttpMessageConverter and I can see it gets registered. Still, when trying to deserialize, I see that it is not using my custom MappingJackson2HttpMessageConverter but that instead it uses the defaultList of HttpMessageConverters (in other words it's not overridden). Any idea how it could be solved ? Thanks.
package com.bigid.scanner.service.restapi;
import com.bigid.scanner.api.datalink.DataLink;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.text.SimpleDateFormat;
import java.util.List;
@Configuration
@EnableWebMvc
public class WebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.mixIn(DataLink.class, PolymorphicDataLinkMixin.class);
converters.add(new MappingJackson2HttpMessageConverter(builder.build()));
}
}