title: Spring Data JPA - How to programmatically set JpaRepository base packages
body: <p>When defining an EntityManager in a Spring Java Config class, I can add the base packages to scan for Entity classes by calling a method on the corresponding builder:</p>
  
  <pre><code>public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
    // Some other configuration here
    builder.packages("org.foo.bar", "org.foo.baz");
    return builder.build();
  }
  </code></pre>
  
  <p>I need something similar for the places where Spring looks for Repository Interfaces. The usual way is using the <code>@EnableJpaRepositories</code> annotation:</p>
  
  <pre><code>@EnableJpaRepositories(basePackages = {"org.foo.barbaz"})
  </code></pre>
  
  <p>But I would like to have a dynamical way for defining these packages similar to the way above for the Entity locations. Something like this:</p>
  
  <pre><code>public SomeJpaRepositoryFactoryBean entityManagerFactory(JpaRepositoryFactoryBuilder builder) {
    // Some other configuration here
    builder.packages("org.foo.barbaz");
    return builder.build();
  }
  </code></pre>
  
  <p>Is there a way to do this with the current Spring Data JPA release is it simply not meant to be done this way?</p>