title: Spring/DI: Constructor injection in child class
body: <p>I've got a parent class with a constructor injected dependency:</p>
  
  <pre><code>class ParentClass {
    private final MyService service;
  
    @Autowired
    ParentClass(MyService service) {
      this.service=service;
    }
    // ...
  }
  </code></pre>
  
  <p>If I inherit from this class, do I always need to redefine a constructor calling the parent constructor?</p>
  
  <pre><code>class ChildClass extends ParentClass {
    // Do I really need this?
    @Autowired
    ChildClass(MyService service) {
      super(service);
    }
    // ...
  }
  </code></pre>
  
  <p>Using setter injection, I seem to be able to keep the dependency in the parent class and do not need to rewire it in the child, which sounds good to me if the child class does not touch the functionality linked to the dependency:</p>
  
  <pre><code>class ParentClass {
    private MyService service;
  
    @Autowired
    void setMyService(MyService service) {
      this.service=service;
    }
    // ...
  }
  
  class ChildClass extends ParentClass {
    // ...
  }
  </code></pre>
  
  <p>It seems that if I want to avoid repeating the autowiring code and handling the dependency in the child, I can only do this using setter or field injection. </p>
  
  <p>Is there a cleaner pattern to do this dependency injection or is this a case where field/setter injection has to be used, even though constructor injection is recommended?</p>
  
  <p>Thanks!</p>