Noticing that by default, Jackson2JsonEncoder/Decoder (as used by BaseDefaultCodecs) use new instances of Jackson2ObjectMapperBuilder (calling a static method on Jackson2ObjectMapperBuilder which in turn invokes the constructor) and not a bean. As a result, we miss any configuration done in org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration. In my case, I was using WebFlux, and was able to work around this by using a WebFluxConfigurer to create an encoder using the autowired ObjectMapper - though I would have expected using the configured builder to be the default. See also: https://stackoverflow.com/questions/43195987/configured-objectmapper-not-used-in-spring-boot-webflux
Would it make sense/be possible to have Jackson2JsonEncoder/Decoder use an injected Jackson2ObjectMapperBuilder bean if it exists, and fallback to the static method if not?
Comment From: bclozel
I believe this is done by design. Classes should express the required dependencies in their constructor and by no means Spring infrastructure components should perform container lookup themselves - only configuration infrastructure should do so, using injection mechanisms if possible.
The class already provides another constructor for that case.