Duplicate StringHttpMessageConverter Duplicate MappingJackson2HttpMessageConverter
Comment From: bclozel
Hi @brucelwl
This behavior is intentional and is documented. See #1293, #2444, #20235 and #15027 for more information on that (and duplicate issues in some cases).
The bottom line is: they're not really duplicate because they might not have the same configuration and one or the other might be used depending on the case.
Thanks!
Comment From: brucelwl
But the configuration in org.springframework.http.converter.json.MappingJackson2HttpMessageConverter is exactly the same
Comment From: bclozel
@brucelwl the ObjectMapper instances aren't the same. See #1293 as mentioned in my previous comment.
Comment From: brucelwl
@bclozel I have roughly understood what you mean, but what should I do if I don't want to use the default converter? I think we should replace the converter instead of appending the converter before the default to avoid creating redundant objects. The media types to be supported can be customized by developers
In terms of StringHttpMessageConverter, it is difficult to use the second object because their judgment conditions are the same,
Comment From: hassanrehman01398
@bclozel @brucelwl I have the same question. I have two MappingJackson Convertor of same data type. The modules registered in the first convertor are 5 and in the other one are 2. When I am calling my rest template, the second convertor is been called resulting in error.
Failed to evaluate Jackson deserialization for type com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid type definition for type Argument #0 of constructor com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)} has no property name (and is not Injectable): can not use as property-based Creator