title: Boot-strapping Spring Data JPA without XML
body: <p>What is the Java <code>@Configuration</code> equivalent to:</p>
  
  <pre><code>&lt;repositories base-package="com.acme.repositories" /&gt;
  </code></pre>
  
  <p>in <a href="http://www.springsource.org/spring-data/jpa">Spring Data JPA</a>? I am trying to get rid of XML configuration in favour to <code>@Configuration</code> classes, however reading through <a href="https://github.com/SpringSource/spring-data-jpa/blob/master/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigDefinitionParser.java">JpaRepositoryConfigDefinitionParser</a> sources is fruitless.</p>
  
  <p>The closest what I can get is:</p>
  
  <pre><code>@Bean
  public RepositoryFactorySupport repositoryFactory() {
      return new JpaRepositoryFactory(entityManagerFactory().createEntityManager())
  }
  
  @Bean
  public BookDao bookDao() {
      return repositoryFactory().getRepository(BookDao.class)
  }
  </code></pre>
  
  <p>However the <code>&lt;repositories/&gt;</code> tag is much more functional: it <em>automatically</em> creates DAO for all interfaces extending <code>CrudRepository</code> found on CLASSPATH. Also it seems like my solution does not apply transactions to DAOs as opposed to default Spring Data JPA behaviour.</p>