title: How can I define a custom ObjectMapper bean without overriding the one used by Spring Boot
body: <p>I have a Spring Boot web app with several <code>@RestController</code> classes.
  I like the default json format returned by my REST controllers.</p>
  
  <p>For use in my DAO beans (which do json serialization and deserialization ), I have created a custom <code>ObjectMapper</code>:</p>
  
  <pre><code>@Configuration
  public class Config{
  
    @Bean
    public ObjectMapper getCustomObjectMapper() {
      final ObjectMapper objectMapper = new ObjectMapper();
      objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
      objectMapper.setPropertyNamingStrategy(new PropertyNamingStrategy.SnakeCaseStrategy());
      return objectMapper;
    }
  }
  </code></pre>
  
  <p>And in each of my DAO classes I autowire my custom <code>ObjectMapper</code>:</p>
  
  <pre><code>@Repository
  @Transactional
  public class MyDaoImpl implements MyDao {
  
  @Autowired
  ObjectMapper objectMapper
  
  //Dao implementation...
  
  }
  </code></pre>
  
  <p>This all works fine. The problem is that my custom <code>ObjectMapper</code> gets automatically picked up by Spring and is used for serializing REST responses.<br>
  This is undesirable. For REST controllers I want to keep the <code>ObjectMapper</code> that Spring creates by default.</p>
  
  <p>How can I tell Spring Boot to <strong>not</strong> detect and <strong>not</strong> use my custom <code>ObjectMapper</code> bean for its own internal workings?</p>