title: "Could not find acceptable representation" using spring-boot-starter-web
body: <p>I am trying to use <code>spring-boot-starter-web</code> to create a rest service serving up JSON representations of Java objects. From what I understand this boot-starter-web jar is supposed to handle the conversion to JSON through Jackson automatically but I am instead getting this error.</p>
  
  <pre><code>{ 
    "timestamp": 1423693929568,
    "status": 406,
    "error": "Not Acceptable",
    "exception": "org.springframework.web.HttpMediaTypeNotAcceptableException",
    "message": "Could not find acceptable representation"
  }
  </code></pre>
  
  <p>My Controller is this...</p>
  
  <pre><code>@RestController
  @RequestMapping(value = "/media")
  public class MediaController {
      @RequestMapping(value = "/test", method = RequestMethod.POST)
      public @ResponseBody UploadResult test(@RequestParam(value="data") final String data) {
        String value = "hello, test with data [" + data + "]"; 
        return new UploadResult(value);
      }
  
      @RequestMapping(value = "/test2", method = RequestMethod.POST)
      public int test2() {
          return 42;
      }
  
      @RequestMapping(value = "/test3", method = RequestMethod.POST)
      public String test3(@RequestParam(value="data") final String data) {
          String value = "hello, test with data [" + data + "]"; 
          UploadResult upload = new UploadResult(value);
          return upload.value;
      }
  
  
      public static class UploadResult {
          private String value;
          public UploadResult(final String value)
          {
              this.value = value;
          }
      }
  }
  </code></pre>
  
  <p>My <code>pom.xml</code> has...</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;version&gt;1.2.1.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
      &lt;version&gt;1.2.1.RELEASE&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><code>mvn dependency:tree</code> shows that spring-boot-starter-web does indeed depend on the jackson2.4 databind and thus should be on the classpath...</p>
  
  <pre><code>[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.2.1.RELEASE:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter:jar:1.2.1.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot:jar:1.2.1.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.2.1.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.2.1.RELEASE:compile
  [INFO] |  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.8:compile
  [INFO] |  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.8:compile
  [INFO] |  |  \- org.yaml:snakeyaml:jar:1.14:runtime
  [INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.4:compile
  [INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.0:compile
  [INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.4.4:compile
  [INFO] |  +- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile
  [INFO] |  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
  [INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
  [INFO] |  |  \- com.fasterxml:classmate:jar:1.0.0:compile
  [INFO] |  +- org.springframework:spring-web:jar:4.1.4.RELEASE:compile
  [INFO] |  |  +- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
  [INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:compile
  [INFO] |  |  +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
  [INFO] |  |  \- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
  [INFO] |  \- org.springframework:spring-webmvc:jar:4.1.4.RELEASE:compile
  [INFO] |     \- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
  </code></pre>
  
  <p>... yet calling the <code>test</code> service gives the error mentioned above. <code>test2</code> and <code>test3</code> work fine proving that it must just be the attempted conversion to JSON that is failing? Am I missing some configuration problem or annotations? From all the examples I can find, annotating the class for basic Jackson JSON conversion is no longer necessary.</p>
  
  <p>Any help greatly appreciated.</p>