title: what is the best way to autowire parent class field in spring?
body: <p>When I use spring framework, I find something that should be extract, for example, the service component (or member variable that is autowired).
  Code show as below:</p>
  
  <pre><code>abstract class Payment {
  
      PaymentService paymentService;
  
      void setPaymentService(OrderPaymentService paymentService) {
          this.paymentService = paymentService;
      }
  
  }    
  
  @Component
  public class CancelPayment extends Payment{
      private OtherService2 otherSerivce2;
  
      @Autowired
      @Override
      public void setPaymentService(PaymentService paymentService) {
          super.setPaymentService(paymentService);
      }
  
      @Autowired
      public CancelPayment(OtherService2 s2) {
          this.otherSerivce2 = s2;
      }
  }
  
  @Component
  public class CreatePayment extends Payment{
      private OtherService1 otherSerivce1;
  
      @Autowired
      @Override
      public void setPaymentService(PaymentService paymentService) {
          super.setPaymentService(paymentService);
      }
  
      @Autowired
      public CreatePayment (OtherService1 s1) {
          this.otherSerivce1 = s1;
      }
  }
  </code></pre>
  
  <p>As you can see, I use setter injection in each child class. Is this a better practice than autowire their parent's member variable?</p>