title: Can not autowire interface
body: <p>When I try to autowire a interface from my controller I get the exception below:
  StackTrace:</p>
  
  <pre><code>Could not autowire field: com.projectShaun.service.AccountService com.projectShaun.controller.HomeController.accountService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.projectShaun.dao.AccountDao com.projectShaun.service.AccountServiceImpl.accountDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.hibernate.SessionFactory com.projectShaun.dao.AccountDaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  </code></pre>
  
  <p>My controller looks like this:</p>
  
  <pre><code>package com.projectShaun.controller;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  import com.projectShaun.service.AccountService;
  
  @Controller
  public class HomeController {
  
      @Autowired
      AccountService accountService;
  
      @RequestMapping("/")
      public ModelAndView welcome() {
          ModelAndView modelAndView = new ModelAndView("welcome");
          modelAndView.addObject("greeting", "Welcome to projectShaun!");
          return modelAndView;
      }
  }
  </code></pre>
  
  <p>And my application-context:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
      xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:task="http://www.springframework.org/schema/task"
      xsi:schemaLocation="http://www.springframework.org/schema/aop 
      http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.2.xsd 
      http://www.springframework.org/schema/jee 
      http://www.springframework.org/schema/jee/spring-jee-3.2.xsd 
      http://www.springframework.org/schema/tx 
      http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
      http://www.springframework.org/schema/task 
      http://www.springframework.org/schema/task/spring-task-3.2.xsd" &gt;
  
    &lt;context:component-scan base-package="com.projectShaun.controller" /&gt;
  
    &lt;tx:annotation-driven/&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:3306/projectshaun" /&gt;
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
       &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.projectShaun.model.Account&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
        &lt;props&gt;
          &lt;prop 
           key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
          &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
        &lt;/props&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  
    &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" 
      p:sessionFactory-ref="sessionFactory"&gt;
    &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>I am not sure why it is throwing this exception, I am not sure if it's something to do with the context: component scan base. I tried just putting <code>com.projectShaun</code> as the base package.</p>
  
  <p>AccountDAO:</p>
  
  <pre><code>package com.projectShaun.dao;
  
  import com.projectShaun.model.Account;
  
  public interface AccountDao {
  
  void persistAccount (Account account);
  }
  </code></pre>