title: I can't autowire repository in spring
body: <p>I am trying to autowire repository in controller using spring annotation. I am getting error <code>org.springframework.data.repository.query.QueryByExampleExecutor class not found</code> for which I couldn't find a solution.</p>
  
  <p>Error that I am getting:</p>
  
  <pre class="lang-none prettyprint-override"><code>SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'articleController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.payforeign.article.ArticleRepository com.payforeign.article.ArticleController.repository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'articleRepository': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/query/QueryByExampleExecutor
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>package com.payforeign.article;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  @Controller
  @RequestMapping("/service")
  public class ArticleController {
  
     @Autowired
     private ArticleRepository repository;
  
     //controller methods
  }
  </code></pre>
  
  <p><strong>Repository</strong></p>
  
  <p>I have annotated repository with <code>@Repository</code>. According to spring documentation I am having only repository interface. Is it correct?</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.payforeign.article;
  
  import org.springframework.data.repository.CrudRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface ArticleRepository extends CrudRepository&lt;Article, Long&gt; {}
  </code></pre>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <p>I have included <code>jpa:repositories</code> with correct <code>base-package</code> and <code>component-scan</code>. I have specified that it is annotation driven (<code>&lt;mvc:annotation-driven /&gt; &lt;tx:annotation-driven /&gt;</code>) and added JDBC and JPA settings. My applicationContext.xml is correctly loaded from web.xml</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;beans ...&gt;
      &lt;context:component-scan base-package="com.payforeign,com.payforeign.article" /&gt;
      &lt;mvc:annotation-driven /&gt;
      &lt;jpa:repositories base-package="com.payforeign.article" /&gt;
  
      &lt;!-- Data Source --&gt;
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" &gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost/payforeign" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Hibernate --&gt;
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="packagesToScan" value="com.payforeign.article" /&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                  &lt;property name="showSql" value="true" /&gt;
                  &lt;property name="generateDdl" value="true" /&gt;
                  &lt;property name="database" value="MYSQL" /&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- enable the configuration of transactional behavior based on annotations --&gt;
      &lt;tx:annotation-driven /&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>