I have gone through other similar asked questions but nothing worked for me.
All my API\'s return JSON as response by Default:
In general if you want to get json response you need an jackson-databind module:
com.fasterxml.jackson.core
jackson-databind
${json-jackson-version}
and then you have to define a MappingJackson2HttpMessageConverter in your configuration:
@Configuration
@EnableWebMvc
public class WebAppMainConfiguration extends WebMvcConfigurerAdapter {
@Override
public void configureMessageConverters(List> converters) {
converters.add(new MappingJackson2HttpMessageConverter());
[..]
super.configureMessageConverters(converters);
}
[...]
}
In your case, you can implement your own AbstractGenericHttpMessageConverter so you can switch in this converter between different concrete converters depending on media type.
Check the method AbstractGenericHttpMessageConverter#writeInternal(..)