title: Could not autowire field, but I have the definition
body: <p>My app-config.xml has a definition for my UserDao bean:</p>
  
  <pre><code>  &lt;bean id="userDao" class="com.blah.core.db.hibernate.UserDaoImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>I have my component scanning:</p>
  
  <pre><code>&lt;context:component-scan base-package="com.blah" /&gt;
  </code></pre>
  
  <p>My index action in my HomeController works fine (it outputs the contents of a method on my UserService to a freemarker template).</p>
  
  <pre><code>@Controller
  public class HomeController {
  
      @Autowired
      private UserService userService;
  
  
  
  
      @RequestMapping("/")
      public ModelAndView Index() {
  
  
  
          ModelAndView mav = new ModelAndView();
  
          mav.setViewName("index");
          mav.addObject("message", userService.sayHello());
  
          mav.addObject("username", userService.getTestUser());
  
  
          return mav;
      }
  </code></pre>
  
  <p>The 'getTestUser()' is a new method that makes reference to UserDao, it looks like:</p>
  
  <pre><code>@Service
  public class UserServiceImpl implements UserService{
  
      @Autowired
      UserDao userDao;
  
      public String sayHello() {
  
          return "hello from user service impl part 2";
  
      }
  
      public String getTestUser() {
  
  
          return userDao.getById(1L).getUsername();
  
      }
  
  
  }
  </code></pre>
  
  <p>I am getting the error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.blah.core.db.hibernate.UserDao com.blah.core.services.UserServiceImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.blah.core.db.hibernate.UserDao] 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>
  
  <ol>
  <li>What could the issue be?</li>
  <li>If I didn't do autowire, what would I be doing instead of adding the @AutoWire on the UserDao definition.</li>
  </ol>