title: Spring Boot REST with XML Support
body: <p>I made a simple REST webservice with Spring Boot 1.2.5 and it works fine for JSON but I can't make this work to return XML. </p>
  
  <p>This is my controller:</p>
  
  <pre><code>@RestController
  ..
  @RequestMapping(method = RequestMethod.GET,  produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
  @ResponseStatus(HttpStatus.OK)
  public List&lt;Activity&gt; getAllActivities() {
      return activityRepository.findAllActivities();
  }
  </code></pre>
  
  <p>When I call it with <code>Accept: application/json</code> everything works, but when I try with <code>application/xml</code> I get some HTML with 406 Error and message:</p>
  
  <pre><code>The resource identified by this request is only capable of generating responses 
  with characteristics not acceptable according to the request "accept" headers.
  </code></pre>
  
  <p>My model objects:</p>
  
  <pre><code>@XmlRootElement
  public class Activity {
  
      private Long id;
      private String description;
      private int duration;
      private User user; 
      //getters &amp; setters...
  }
  
  @XmlRootElement
  public class User {
  
      private String name;
      private String id;
      //getters&amp;setters...
  }
  </code></pre>
  
  <p>My pom.xml</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.2.5.RELEASE&lt;/version&gt;
      &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&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;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>Do I need some additional jars in my pom.xml to make this work? I tried adding jaxb-api or jax-impl but it didn't help.</p>