title: spring - autowiring interface in abstract class with scope prototype does not work
body: <p>I have an <a href="https://github.com/MaxHoefl/autowire-abstract" rel="nofollow noreferrer">example spring project</a> where I have an abstract class <code>Athlete</code> into which I want to autowire an interface <code>Trainer</code>.</p>
  
  <p>The <code>Athlete</code> is <code>Runnable</code> and implementations thereof override a <code>perform()</code> method. </p>
  
  <p>When I call <code>perform()</code> in <code>Sprinter</code> (extends <code>Athlete</code>) the <code>Trainer</code> instance that I wanted to autowire into <code>Athlete</code> is still null</p>
  
  <p>Athlete:</p>
  
  <pre><code>@Component
  @Scope("prototype")
  public abstract class Athlete implements Runnable{
  
      protected final String name;
  
      @Autowired protected Trainer trainer;
  
  
      public Athlete(String name)
      {
          this.name = name;
      }
  
      protected abstract void perform();
  
      @Override
      public void run() {
          perform();
      }
  }
  </code></pre>
  
  <p>Sprinter:</p>
  
  <pre><code>@Component
  @Scope("prototype")
  public class Sprinter extends Athlete {
  
      public Sprinter(String name) {
          super(name);
      }
  
      @Override
      protected void perform() 
      {
          this.trainer.giveAdviceTo(name); // TRAINER IS NULL !!!!!!
          for(int i=0;i&lt;3;i++)
          {
              System.out.println("Sprinting...");
              try {
                  Thread.sleep(1000);
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
      }
  }
  </code></pre>
  
  <p>Implementation of <code>Trainer</code></p>
  
  <pre><code>@Component
  public class TrainerImpl implements Trainer{
  
      @Override
      public void giveAdviceTo(String name)
      {
          System.out.println("Go " + name + "!!");
      }
  }
  </code></pre>
  
  <p>Thanks for the help</p>