title: Autowire Bean again or use getter?
body: <p>I have an abstract class, which autowires some beans, for example a repository:</p>
  
  <pre><code>public abstract class A {
      @Autowired
      private ARepository aRepository;
  
      protected void useRepository() {
          aRepository.doSomething();
      }
  }
  </code></pre>
  
  <p>This abstract class uses that repository for some method. Now I also have a child class, which extends class <code>A</code> and also has a method, which uses <code>ARepository</code>.</p>
  
  <pre><code>public class B extends A {
  
      private void useRepositoryAgain() {
          aRepository.doSomething();
      }
  }
  </code></pre>
  
  <p>Now my question: </p>
  
  <p>How I see it there are two ways to do this: </p>
  
  <p>1: Autowire the repository in class <code>B</code> again:</p>
  
  <pre><code>public class B extends A {
      @Autowired
      private ARepository aRepository;
      ...
  }
  </code></pre>
  
  <p>2: Create a getter method in class A:</p>
  
  <pre><code>public abstract class A {
      ...
      public ARepository getARepository() {
          return this.aRepository;
      }
  }
  
  public class B extends A {
  
      private void useRepositoryAgain() {
          getARepository().doSomething();
      }
  }
  </code></pre>
  
  <p>In my understanding, there shouldn't be a difference between the two, as autowiring the repository again would just return the same instance of it. </p>
  
  <p>Is my understanding correct, or is there some significant difference between the two approaches which I am missing?</p>