title: Jackson deserialize GeoJson Point in Spring Boot
body: <p>I have a <code>@Entity</code> model that has a property of type <code>com.vividsolutions.jts.geom.Point</code>. When I try to render this model in a <code>@RestController</code> I get a recursion exception. </p>
  
  <pre><code>(StackOverflowError); nested exception is 
  com.fasterxml.jackson.databind.JsonMappingException: Infinite 
  recursion (StackOverflowError) (through reference chain: 
  com.vividsolutions.jts.geom.Point[\"envelope\"]-
  &gt;com.vividsolutions.jts.geom.Point[\"envelope\"]....
  </code></pre>
  
  <p>The entity looks like this (shortened for brevity): </p>
  
  <pre><code>@Entity
  @Data
  public class MyEntity{
      // ...
      @Column(columnDefinition = "geometry")
      private Point location;
      // ...
  }
  </code></pre>
  
  <p>After some research I found out that this is because Jackson cannot deserialize GeoJson by default. Adding this library should solve the issue: <a href="https://github.com/bedatadriven/jackson-datatype-jts" rel="noreferrer">https://github.com/bedatadriven/jackson-datatype-jts</a>.</p>
  
  <p>I am now not sure how to include this module in the object mapper in spring boot. As per documentation in boot, I tried adding it to the <code>@Configuration</code> in the following two ways:</p>
  
  <pre><code>@Bean
  public Jackson2ObjectMapperBuilder jacksonBuilder() {
      Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
      builder.modulesToInstall(new JtsModule());
      return builder;
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Bean
  public JtsModule jtsModule(){
      return new JtsModule();
  }
  </code></pre>
  
  <p>Both didn't remove the exception. Sry if this is a duplicate, but all I was able to find SO were customising the <code>ObjectMapper</code> which in my understanding of the documentation is no the "spring boot way".</p>
  
  <p>As a workaround I am <code>@JsonIgnore</code>ing the <code>Point</code> and have custom getters and setters for a non existent coordinated object,... but it's not the way I'd like to keep it.</p>