title: Spring data entities in different packages
body: <p>I am new to spring and want to use the following project structure in spring boot application. </p>
  
  <ol>
  <li>Different package for each type of entity and its corresponding repository implementation.</li>
  <li>A Package for repository configuration</li>
  </ol>
  
  <p>*</p>
  
  <pre><code>**com.demo.Customer**
      Customer.java
      CustomerRepository.java
      Application.java
  
  **com.demo.Order**
      Order.java
      OrderRepository.java
  
  **com.demo.config**
      ApplicationConfig.java
      CustomerConfig.java
      OrderConfig.java
  </code></pre>
  
  <p><strong>CustomerConfig.java</strong></p>
  
  <pre><code>import com.demo.cstore.core.Customer;
  @Configuration
  @EnableJpaRepositories(basePackageClasses = Customer.class)
  public class CustomerConfiguration {
  
  }
  </code></pre>
  
  <p><strong>Application.java</strong></p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan(basePackages = {"com.demo.order"}) //inject repository from other packages
  public class Application {
      private static final Logger log = LoggerFactory.getLogger(Application.class);
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class);
      }
  </code></pre>
  
  <p>After compiling and running the application, only customer entity is created. Is that because application file just recognizes customer entity as it exists in the same package <strong>com.demo.Customer</strong>. How can Order entity be injected and and an entity is created?</p>