title: Is it possible to have a Jackson custom deserializer with non-default constructor?
body: <p>Lets say that I have the following classes: </p>
  
  <pre><code>public class Person {
  
      String name;
      Set&lt;Department&gt; departments;
  
  }
  
  public class Department {
  
      String code;
      String name;
  
  }
  </code></pre>
  
  <p>So I want to write a custom Department deserializer in order to annotate the deparments field in the Person class to use it. Because this custom deserializer will only be used to deserialize Department objects that are inside a Person object. The problem is that my custom Department deserializer will need to have a DepartmentRepository that must be passed in the deserializer's constructor. How can I do this? Is this possible? I don't want to register the deserializer in the object mapper because it must only be used when the deparatments field from the Person class gets deserialized.</p>
  
  <p><strong>UPDATE:</strong> What I need is, apart from annotate the departments field with JsonDeserialize annotation with the parameter contentUsing = MyCustomDepartmentDeserializer.class, is a way to tell Jackson that when it creates a MyCustomDepartmentDeserializer object, it must done it by calling a constructor that receives a DepartmentRepository. The deserializer may be something like this: </p>
  
  <pre><code>public class MyCustomDepartmentDeserializer extends JsonDeserializer&lt;Department&gt; {
  
      private final DepartmentRepository departmentRepository;
  
      public MyCustomDepartmentDeserializer(DepartmentRepository departmentRepository) {
          this.departmentRepository = departmentRepository;
      }
  
      @Override
      public Department deserialize(JsonParser jp, DeserializationContext ctxt)
      throws IOException, JsonProcessingException {
          //IMPLEMENTATION!
      }
  
  }
  </code></pre>