title: Instantiate Java Spring repository interface without @Autowire
body: <p>This is my Spring repository interface.</p>
  
  <pre><code>@Repository
  public interface WebappRepository extends CrudRepository&lt;myModel, Long&gt; {
  
  }
  </code></pre>
  
  <p>In my controller, I can instantiate the <code>WebappRepository</code> even though it's an interface, because of Spring annotation magic.</p>
  
  <pre><code>public class controller{
  
      @Autowire
      WebappRepository repo;
  
      public controller(){
  
      }
  }
  </code></pre>
  
  <p>But this variant, using the constructor, does <em>not</em> work, and rightly so, because WebappRepository is an interface.</p>
  
  <pre><code>public class controller{
  
      WebappRepository repo;
  
      public controller(){
          this.repo = new WebappRepository();
      }
  }
  </code></pre>
  
  <p>Olivier Gierke himself <a href="http://olivergierke.de/2013/11/why-field-injection-is-evil/" rel="nofollow noreferrer">advocates to avoid <code>@Autowire</code> fields at all costs</a>. How can I "instantiate" the repository interface in my Spring application while avoiding the <code>@Autowire</code>?</p>