title: Spring Data JPA returning null repositories
body: <p>When working with Spring Boot and Spring Data JPA, I'm getting null repositories when <code>@Autowiring</code>.</p>
  
  <p>I may have missed some piece of simple configuration, but after hours looking at it and reviewing the docs I find no flaws. I need antoher pair of eyes to take a fresh look.</p>
  
  <p>Here is the relevant configuration:</p>
  
  <pre><code>@SpringBootApplication
  @EnableJpaRepositories
  @EnableTransactionManagement
  public class ServerApp {
    public static void main(String[] args) {
      SpringApplication.run(ServerApp.class, args);
    }
  }
  </code></pre>
  
  <p>A Service using the repository. When executing <code>doSomething()</code> the <code>repository</code> is null. </p>
  
  <pre><code>@Service
  @Slf4j
  public class MyService{
    @Autowired
    private MyRepository repository;
  
    @Override
    public AnEntity doSomething(String index) {
      return repository.findOneByIndex(index);
    }
  }
  </code></pre>
  
  <p>The Repository</p>
  
  <pre><code>public interface MyRepository extends   JpaRepository&lt;AnEntity, String&gt; {
    AnEntity findOneByIndex(String index);
  }
  </code></pre>
  
  <p>The Entity</p>
  
  <pre><code>@Entity
  @Table(name = "entities")
  @Getter
  @Setter
  @ToString
  public class AnEntity implements Serializable{
    private static final long serialVersionUID = -6256451671609986911L;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    private String index;
    private String data;
  }
  </code></pre>
  
  <p>The persistence.xml file</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;persistence
      xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
      version="2.0"&gt;
  &lt;persistence-unit name="default"&gt;
      &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
      &lt;class&gt;com.myapp.AnEntity&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.show_sql" value="true" /&gt;
          &lt;property name="javax.persistence.transactionType" value="RESOURCE_LOCAL" /&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/authServer" /&gt;
          &lt;property name="javax.persistence.jdbc.user" value="user" /&gt;
          &lt;property name="javax.persistence.jdbc.password" value="password" /&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>The POM</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://maven.apache.org/POM/4.0.0"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;com.myapp&lt;/groupId&gt;
  &lt;artifactId&gt;myapp&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  &lt;packaging&gt;pom&lt;/packaging&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.2.7.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.plugin&lt;/groupId&gt;
          &lt;artifactId&gt;spring-plugin-core&lt;/artifactId&gt;
          &lt;version&gt;1.2.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.4-1201-jdbc41&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;net.logstash.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logstash-logback-encoder&lt;/artifactId&gt;
          &lt;version&gt;4.5.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
          &lt;artifactId&gt;lombok&lt;/artifactId&gt;
          &lt;version&gt;1.16.6&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.12&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
          &lt;artifactId&gt;json-path&lt;/artifactId&gt;
          &lt;version&gt;2.0.0&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;br.com.six2six&lt;/groupId&gt;
          &lt;artifactId&gt;fixture-factory&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;log4j&lt;/groupId&gt;
                  &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>