title: Spring @RestController custom JSON deserializer
body: <p>I want to use custom JSON deserializer for some classes(<strong>Role</strong> here) but I can't get it working. The custom deserializer just isn't called.</p>
  
  <p>I use Spring Boot 1.2.</p>
  
  <p>Deserializer:</p>
  
  <pre><code>public class ModelDeserializer extends JsonDeserializer&lt;Role&gt; {
  
      @Override
      public Role deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
          return null; // this is what should be called but it isn't
      }
  }
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>@RestController
  public class RoleController {
  
      @RequestMapping(value = "/role", method = RequestMethod.POST)
      public Object createRole(Role role) {
          // ... this is called
      }
  }
  </code></pre>
  
  <ol>
  <li><p><code>@JsonDeserialize</code> on Role</p>
  
  <pre><code>@JsonDeserialize(using = ModelDeserializer.class)
  public class Role extends Model {
  
  }
  </code></pre></li>
  <li><p><code>Jackson2ObjectMapperBuilder</code> bean in Java Config</p>
  
  <pre><code>@Bean
  public Jackson2ObjectMapperBuilder jacksonBuilder() {
      Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
      builder.deserializerByType(Role.class, new ModelDeserializer());
      return builder;
  }
  </code></pre></li>
  </ol>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT</strong> It is probably caused by <code>@RestController</code> because it works with <code>@Controller</code>...</p>