title: Unable to get different Content-Types in request mapping using Spring Framework
body: <p>Here is my controller class:</p>
  <pre><code>@Controller
  @RequestMapping(&quot;/actuator&quot;)
  public class HealthController {
  
      @RequestMapping(value = &quot;/metrics&quot;, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON)
      @ResponseBody
      public HealthModel getDump() throws JsonProcessingException {
          return new HealthModel();
          //return mapper.writeValueAsString(metrics.invoke());
      }
  
      @RequestMapping(value = &quot;/metrics&quot;, method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN)
      @ResponseBody
      public String getHealth() {
          return &quot;HEALTHY&quot;;
      }
  }
  </code></pre>
  <p>Model:</p>
  <pre><code>public class HealthModel {
  
      @JsonProperty
      private String status;
      @JsonProperty
      private int id;
  
      public HealthModel(){
          this.status=&quot;WARN&quot;;
          this.id=2;
      }
  
  }
  </code></pre>
  <p>Note I have mapped <code>/metrics</code> to return <code>json</code> or <code>plain-text</code> depending on the <code>Accept Header</code> in the request</p>
  <p>When I make request at</p>
  <p><code>curl -v -H &quot;Accept: application/json&quot; http://localhost:8080/myapp/actuator/metrics</code></p>
  <p>I get expected response in json
  <code>{&quot;status&quot;:&quot;WARN&quot;,&quot;id&quot;:2}</code>.</p>
  <p>However, when I try</p>
  <p><code>curl -v -H &quot;Accept: text/plain&quot; http://localhost:8080/myapp/actuator/metrics</code></p>
  <p>I get <code>HTTP/1.1 406 Not Acceptable</code>.</p>
  <hr />
  <h2>EDIT</h2>
  <pre><code>@EnableWebMvc
  @Configuration
  public class AppMvcConfig extends WebMvcConfigurerAdapter {
  
     @Resource(name = &quot;appObjectMapper&quot;)
      private ObjectMapper appObjectMapper;
  
      @Resource(name = &quot;modelObjectMapper&quot;)
      private ObjectMapper modelObjectMapper;
  
   @Override
      public void configureMessageConverters(List&lt;HttpMessageConverter&lt;?&gt;&gt; converters) {
         
          final MappingJackson2HttpMessageConverter inputConverter = new MappingJackson2HttpMessageConverter();
          inputConverter.setObjectMapper(appObjectMapper);
  
          final MappingJackson2HttpMessageConverter outputConverter = new MappingJackson2HttpMessageConverter();
          outputConverter.setObjectMapper(modelObjectMapper);
  
          converters.add(new JacksonDualMapperConverter(appObjectMapper, modelObjectMapper));
  
          super.configureMessageConverters(converters);
      }
  
  }
  </code></pre>