Spring 4.1 instantiates a Jackson ObjectMapper
instance. I have reason to want to @Autowire
that instance into one of my controllers: The controller does some minor JSON parsing of its own using Jackson, but the ObjectMapper
it uses should be the one and same instance that Spring itself is using. How do I go about accomplishing that?
Note that I'm not asking how to custom configure the ObjectMapper
in use by Spring; I'm happy with the defaults. I just want to fish the instance used by Spring out so that I can re-use the existing instance in my own code.
@Autowire
property of typeObjectMapper
in the controller is not enough. Apparently, Spring does not expose it as a standard bean. – Canvass@Autowired
onObjectMapper
and@JsonTest
on test class – Orgiastic