title: Spring JPA bean not found exception
body: <p>i am using spring JPA in my project. My repository bean is not getting called. I get a null pointerException.</p>
  
  <p>My Repository is: </p>
  
  <pre><code>public interface UserRepository extends JpaRepository&lt;User, Long&gt;{
  
  }
  </code></pre>
  
  <p>My entity URL:</p>
  
  <pre><code>@Entity
  @Table(name = "user")
  public class User {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      long id;
  
      @Column(name = "emailid")
      String emailId;
  
      @Column(name="role")
      UserRole role;
  
  
  }
  </code></pre>
  
  <p>My JPA Configuration:</p>
  
  <pre><code>@Configuration
  @EnableJpaRepositories(entityManagerFactoryRef = "appentitymanagerfactory",
  transactionManagerRef = "apptransactionmanager",
  basePackages = "com.tree.employeeapp.entity")
  public class JpaConfiguration {
      @Bean
      (name = "appentitymanagerfactory")
      public LocalContainerEntityManagerFactoryBean externalEntityManagerFactory(
           EntityManagerFactoryBuilder   builder, @Qualifier("employeeappdatasource") DataSource dataSource) {
          return builder.dataSource(dataSource)
                  .packages("com.tree.employeeapp.entity")
                  .build();
      }
  
      @Bean(name = "apptransactionmanager")
        public PlatformTransactionManager barTransactionManager(
          @Qualifier("appentitymanagerfactory") EntityManagerFactory
          entityManagerFactory
        ) {
          return new JpaTransactionManager(entityManagerFactory);
        }
  }
  </code></pre>
  
  <p>My controller is this: </p>
  
  <pre><code>@Controller
  public class treeAppsControllerImpl implements treeAppsController{
  
  private UserRepository userRepository;
  @Autowired
  public treeAppsControllerImpl(UserRepository userRepository) {
      this.userRepository = userRepository;
  }
  
  @Override
  public String getAllUsers(Model model) {
      List&lt;Users&gt; listOfUsers = new ArrayList&lt;&gt;();
  
      for(User user: userRepository.findAll())
              listOfUser.add(user);
  
      List&lt;User&gt; listOfUser = UserRepository.findAll();
      model.addAllAttributes(listOfUsers);
      return "getAllUsers";
  }
  </code></pre>
  
  <p>the log shows this error:</p>
  
  <p><strong>Parameter 0 of constructor in com.tree.employeeapp.controller.treeAppsControllerImpl required a bean of type 'com.tree.employeeapp.repository.UserRepository' that could not be found.
  Action:
  Consider defining a bean of type 'com.tree.employeeapp.repository.UserRepository' in your configuration.</strong></p>