title: Test annotated with @DataJpaTest not autowiring field annotated with @Autowired
body: <p>I have a Spring Boot app which contains a Spring Data Jpa repository. I need to run a unit (or component?) test around this repository. I do not have a lot of experience with Spring Data Jpa.</p>
  
  <p>Here's my test. It's trivially simple, and I cannot get it to pass.</p>
  
  <pre><code>import org.junit.Test;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
  import static org.junit.Assert.assertNotNull;
  
  @DataJpaTest
  public class FooRepositoryTest {
  
      @Autowired
      private FooRepository fooRepo;
  
      @Test
      public void notNull(){
          assertNotNull(fooRepo);
      }
  }
  </code></pre>
  
  <p>Here's the other relevant source code.</p>
  
  <pre><code>import com.fedex.dockmaintenancetool.webservice.types.Foo;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface FooRepository extends JpaRepository&lt;Foo, Long&gt; {
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>import javax.persistence.Entity;
  
  @Entity
  public class Foo {
  }
  </code></pre>
  
  <p>I am <em>just</em> trying to get a Jpa repo autowired into a test, and I can't. Clearly I'm misunderstanding some small nuance of how Spring Boot works. But even after going through some tutorials, I cannot figure out what I'm missing. Could anyone help me with this?</p>