title: Instantiation of bean failed : Specified class is an interface
body: <p>I am facing an issue while creating a bean for dependency injection. Here is the scenario.</p>
  
  <p>I am dealing with MongoDB repository, I have also created a class which uses it. I am trying to instantiate bean instance of both.</p>
  
  <p>MongoDB reporsitory:</p>
  
  <pre><code>@Repository
  public interface ProductGlobalTrendRepository extends MongoRepository&lt;ProductGlobalTrend,String&gt;{
      public ProductGlobalTrend findByPid(@Param("pId") String pId);
  }
  </code></pre>
  
  <p>The class which is using it:</p>
  
  <pre><code>@Service
  @Scope("singleton")
  public class ProductTrendService {
  
      @Autowired
      @Qualifier("productGlobalTrendRepo")
      ProductGlobalTrendRepository productGlobalTrendRepo;
  
      public ProductTrendService() {
          super();
      }   
  
      public void setProductGlobalTrendRepo(
              ProductGlobalTrendRepository productGlobalTrendRepo) {
          this.productGlobalTrendRepo = productGlobalTrendRepo;
      }
  
      public ProductTrendService(ProductGlobalTrendRepository productGlobalTrendRepo) {
          super();
          this.productGlobalTrendRepo = productGlobalTrendRepo;
      }
  }   
  </code></pre>
  
  <p>The spring's bean config xml has these entries:</p>
  
  <pre><code>&lt;bean id="productTrendService" class="com.api.services.ProductTrendService"&gt; &lt;/bean&gt;
  &lt;bean id="productGlobalTrendRepo" class="com.mongodb.repository.ProductGlobalTrendRepository"&gt; &lt;/bean&gt;
  </code></pre>
  
  <p>Following is the error I am getting:</p>
  
  <blockquote>
    <p>19428 [localhost-startStop-1] WARN 
    org.springframework.web.context.support.AnnotationConfigWebApplicationContext
    - Exception encountered during context initialization - cancelling refresh attempt
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'productTrendService': Injection of autowired
    dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: com.mongodb.repository.ProductGlobalTrendRepository
    com.api.services.ProductTrendService.productGlobalTrendRepo; nested
    exception is org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'productGlobalTrendRepo' defined in
    class path resource [com/vstore/conf/spring-security.xml]:
    Instantiation of bean failed; nested exception is
    org.springframework.beans.BeanInstantiationException: <strong>Failed to
    instantiate [com.mongodb.repository.ProductGlobalTrendRepository]:
    Specified class is an interface</strong></p>
  </blockquote>
  
  <p>It complains that repository is a interface class.</p>
  
  <p>Can somebody please suggest a fix/workaround for this bean dependency injection ? </p>