title: No qualifying bean of type available: expected at least 1 bean which qualifies as autowire candidate
body: <p>I have a Hibernate configurations setup like this</p>
  
  <pre><code>    @Configuration
  @PropertySource("classpath:db.properties")
  @ComponentScan("com.fyt.fyt")
  @EnableTransactionManagement
  public class ApplicationContextConfig {
  
      @Autowired
      private Environment env;
  
      @Bean()
      public InternalResourceViewResolver getViewResolver() {
          InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
          internalResourceViewResolver.setPrefix("/WEB-INF/views/");
          internalResourceViewResolver.setSuffix(".jsp");
          return internalResourceViewResolver;
      }
  
      @Bean()
      public DataSource getDataSource() {
          BasicDataSource dataSource = new BasicDataSource();
          dataSource.setDriverClassName(env.getProperty("db.driver"));
          dataSource.setUrl(env.getProperty("db.url"));
          dataSource.setUsername(env.getProperty("db.username"));
          dataSource.setPassword(env.getProperty("db.password"));
          return dataSource;
      }
  
      @Autowired
      @Bean()
      public LocalSessionFactoryBean getSessionFactory() {
  
          LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
          factoryBean.setDataSource(getDataSource());
  
          Properties props = new Properties();
          props.put("hibernate.show_sql", env.getProperty("hibernate.show_sql"));
          props.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
  
          factoryBean.setHibernateProperties(props);
          factoryBean.setAnnotatedClasses(User.class);
          return factoryBean;
  
      }
      @Autowired
      @Bean()
      public HibernateTransactionManager getTransactionManager() {
          HibernateTransactionManager transactionManager = new HibernateTransactionManager();
          transactionManager.setSessionFactory(getSessionFactory().getObject());
          return transactionManager;
      }
  
      @Autowired
      @Bean()
      public UserDao getUserDao(SessionFactory sessionFactory) {
          return new UserDaoImpl(sessionFactory);
      }
  }
  </code></pre>
  
  <p>And I have UserServiceImpl.java like this</p>
  
  <pre><code>@Service
  public class UserServiceImpl implements UserService {
      @Autowired
      UserDao userDao;
  
      @Transactional
      @Override
      public List&lt;User&gt; list() {
  
          return userDao.list();
      }
  
      @Transactional
      @Override
      public User getUser(int id) {
  
          return userDao.getUser(id);
      }
  
      @Transactional
      @Override
      public void saveOrUpdate(User user) {
          userDao.saveOrUpdate(user);
  
      }
  
      @Transactional
      @Override
      public void delete(int id) {
          userDao.delete(id);
  
      }
  
  }
  </code></pre>
  
  <p>And UserDaoImpl.java like this</p>
  
  <pre><code>@Repository
  public class UserDaoImpl implements UserDao{
      @Autowired
      private SessionFactory sessionFactory;
  
      public UserDaoImpl() {
  
      }
  
      public UserDaoImpl(SessionFactory sessionFactory) {
          this.sessionFactory = sessionFactory;
      }
  
      @Override
      public List&lt;User&gt; list() {
          List&lt;User&gt; users = (List&lt;User&gt;)sessionFactory.getCurrentSession().createCriteria(User.class)
                  .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
          return users;
      }
  
      @Override
      public User getUser(int id) {
          String hql = "from tbl_user where id="+id;
          Query query = sessionFactory.getCurrentSession().createQuery(hql);
          List&lt;User&gt; users = (List&lt;User&gt;)query.list();
          if(!users.isEmpty() &amp;&amp; users != null) {
          return users.get(0);
          }
          return null;
      }
  
      @Override
      public void saveOrUpdate(User user) {
          sessionFactory.getCurrentSession().saveOrUpdate(user);
  
      }
  
      @Override
      public void delete(int id) {
          User usertodelete = new User();
          usertodelete.setId(id);
          sessionFactory.getCurrentSession().delete(usertodelete);
      }
  
  }
  </code></pre>
  
  <p>When I run this I am getting this exception</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'homeController': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.fyt.fyt.daos.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userDao)}
  </code></pre>
  
  <p>I am defining @Repository in UserDaoImpl and @Serice in UserServiceImpl and I am also doing the component scan like this @ComponentScan("com.fyt.fyt") "com.fyt.fyt" is the root level package but still, I am getting this error. What am I doing wrong?</p>