title: Spring Boot : Use custom object mapper/message converter based on end points
body: <p>I want to configure custom message converters based on endpoints. For example, I have below two endpoints in Spring boot controller:</p>
  <pre class="lang-java prettyprint-override"><code>@RequestMapping(value = &quot;/all&quot;, method = RequestMethod.GET)
  public ResponseEntity&lt;Object&gt; findAll{@PageableDefault(size = 10, page = 0) final Pageable pageable){
      //code
  }
      
  @RequestMapping(value = &quot;/object/{id}&quot;, method = RequestMethod.GET)
  public ResponseEntity&lt;Object&gt; byId{@RequestParam(&quot;id&quot; String id){
      //code
  }
  </code></pre>
  <p>For both of these, I want to use different HttpMessageConverter (and in turn, object mapper) instances. E.g. I want to set <code>CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES</code> strategy for <code>/all</code> end point due to it being paged response but not for <code>/object</code>.</p>
  <p>The application already has <code>configureMessageConverters</code> method overridden, with an Objectmapper bean used for all the apis. If I make any change to that, it will be applicable to all the endpoints which is something I don't want.</p>
  <p>Is there any other way to do this? (Something like creating and using custom message converter in the <code>findAll</code> method itself)</p>