title: Spring Data Rest and java.time serialization
body: <p>I've a project without Spring Boot, but it uses some spring modules like "spring data" and "spring data rest".</p>
  
  <p>I've some problem with the serialization of the java.time.* fields.
  I've found some tutorials like <a href="http://lewandowski.io/2016/02/formatting-java-time-with-spring-boot-using-json/" rel="nofollow noreferrer">this</a> but even if I add the following dependency</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
      &lt;version&gt;${jackson.version}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>and the following code in my RepositoryRestConfigurerAdapter</p>
  
  <pre><code>@Component public class CvlRepositoryRestConfigurerAdapter extends RepositoryRestConfigurerAdapter {
  
  @Override
  public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
      config.setDefaultPageSize(75);
      config.setReturnBodyForPutAndPost(Boolean.TRUE);
  }
  
  @Override
  public void configureJacksonObjectMapper(ObjectMapper objectMapper) {
      super.configureJacksonObjectMapper(objectMapper);
      objectMapper.configure(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>my actual response regarding a java.time field is like the following</p>
  
  <p>"rateDate" : {
          "year" : 2017,
          "month" : "FEBRUARY",
          "dayOfMonth" : 14,
          "dayOfWeek" : "TUESDAY",
          "era" : "CE",
          "dayOfYear" : 45,
          "leapYear" : false,
          "monthValue" : 2,
          "chronology" : {
            "id" : "ISO",
            "calendarType" : "iso8601"
          }</p>
  
  <p>What I'm doing wrong? What I'm forgetting?</p>