Hello @ RamaKrishnaRaju,
You should note the Javadoc of configureMessageConverters states first as below.
Configure the HttpMessageConverters to use for reading or writing to the body of the request or response. If no converters are added, a default list of converters is registered.
Note that adding converters to the list, turns off default converter registration. To simply add a converter without impacting default registration, consider using the method extendMessageConverters(java.util.List) instead.
In other words, you've removed all the converters that handle other content types.
Note that Spring MVC only registers the Jackson HttpMessageConverter (MappingJackson2HttpMessageConverter) if the corresponding Jackson libraries are in your classpath. You could remove them and, assuming you have Gson in your classpath, a GsonHttpMessageConverter will be registered for you.
From your code, it seems you want to create a custom GsonHttpMessageConverter. In that case, you can follow the Javadoc instructions and use extendMessageConverters.
A hook for extending or modifying the list of converters after it has been configured. This may be useful for example to allow default converters to be registered and then insert a custom converter through this method.
You'd first want to remove the existing instance, then add your own. For example,
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
// remove the Jackson version if Jackson is still in your classpath
converters.removeIf(converter -> converter instanceof MappingJackson2HttpMessageConverter);
// remove the existing instance (from defaults)
converters.removeIf(converter -> converter instanceof GsonHttpMessageConverter);
// add your custom
converters.add(createGsonHttpMessageConverter());
}
Hope it helps!!