title: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations
body: <p>I am using java based configuration. I have following code setup which showing error.</p>
  <pre><code>public class MyWebInitializer implements WebApplicationInitializer {
      public static Logger logger = Logger.getLogger(MyWebInitializer.class);
  
      @Override
      public void onStartup(ServletContext servletContext) throws ServletException {
          logger.info(&quot;initializing web context&quot;);
          AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = new AnnotationConfigWebApplicationContext();
  
          annotationConfigWebApplicationContext.register(FrontController.class);
  
          ServletRegistration.Dynamic dispatcher = servletContext.addServlet(&quot;dispatcher&quot;,
                  new DispatcherServlet(annotationConfigWebApplicationContext));
  
          dispatcher.setLoadOnStartup(1);
          dispatcher.addMapping(&quot;/&quot;);
  
          logger.info(&quot;On start up method complete&quot;);
      }
  
  }
  </code></pre>
  <p>Front Controller setup:</p>
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan(&quot;com.ishwor.crm.controller,com.ishwor.crm.entity,com.ishwor.crm.DAO&quot;)
  @PropertySource(&quot;classpath:hibenrate.properties&quot;)
  @EnableTransactionManagement
  public class FrontController implements WebMvcConfigurer {
      public static Logger logger = Logger.getLogger(FrontController.class);
  
      @Autowired
      Environment environment;
  
      @Bean
      InternalResourceViewResolver internalResourceViewResolver() {
          logger.info(&quot;inside view resolver function &quot;);
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setPrefix(&quot;/WEB-INF/views/&quot;);
          resolver.setSuffix(&quot;.jsp&quot;);
          resolver.setViewClass(JstlView.class);
          logger.info(&quot;View Resolving complete &quot;);
          return resolver;
      }
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          logger.info(&quot;Inside static resource handler&quot;);
          // for css and js
          registry.addResourceHandler(&quot;/resources/**&quot;).addResourceLocations(&quot;/WEB-INF/resources/&quot;)
                  .setCacheControl(CacheControl.maxAge(2, TimeUnit.HOURS).cachePublic());
          logger.info(&quot;static resource handling complete&quot;);
      }
  
      // hibernate configuration
      @Bean(name = &quot;sessionFactory&quot;)
      public LocalSessionFactoryBean sessionBean() {
          logger.info(&quot;Creating sesion bean&quot;);
          LocalSessionFactoryBean bean = new LocalSessionFactoryBean();
  
          bean.setDataSource(dataSource());
          bean.setPackagesToScan(
                  new String[] { &quot;com.ishwor.crm.entity&quot;, &quot;com.ishwor.crm.DAO&quot;, &quot;com.ishwor.crm.DAOImpl&quot; });
          bean.setHibernateProperties(hibernateProperties());
          logger.info(&quot;Creating sesion bean=== successfull!!!&quot;);
          return bean;
      }
  
      @Bean
      public DataSource dataSource() {
  
          logger.info(&quot;Datasource method invoked&quot;);
  
          DriverManagerDataSource dataSource = new DriverManagerDataSource();
          dataSource.setDriverClassName(environment.getRequiredProperty(&quot;jdbc.driverClassName&quot;));
          dataSource.setUsername(environment.getRequiredProperty(&quot;jdbc.username&quot;));
          dataSource.setPassword(environment.getRequiredProperty(&quot;jdbc.password&quot;));
          dataSource.setUrl(environment.getRequiredProperty(&quot;jdbc.url&quot;));
  
          logger.info(&quot;DataSource Invoke complete&quot;);
  
          return dataSource;
      }
  
      private Properties hibernateProperties() {
          Properties properties = new Properties();
          logger.info(&quot;setting properties for hibernated&quot;);
          properties.put(&quot;hibernate.dialect&quot;, environment.getRequiredProperty(&quot;hibernate.dialect&quot;));
          properties.put(&quot;hibernate.show_sql&quot;, environment.getRequiredProperty(&quot;hibernate.show_sql&quot;));
          properties.put(&quot;hibernate.format_sql&quot;, environment.getRequiredProperty(&quot;hibernate.format_sql&quot;));
          properties.put(&quot;hibernate.hbm2ddl.auto&quot;, environment.getRequiredProperty(&quot;hibernate.hbm2ddl.auto&quot;));
          logger.info(&quot;setting properties completed&quot;);
          return properties;
      }
  
      @Bean
      public HibernateTransactionManager getTransactionManager() {
          HibernateTransactionManager transactionManager = new HibernateTransactionManager();
          transactionManager.setSessionFactory(sessionBean().getObject());
          return transactionManager;
      }
  
  }
  </code></pre>
  <p>Entity Setp:</p>
  <pre><code>
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = &quot;customer&quot;)
  public class Customer {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;id&quot;)
      private long id;
  
      @Column(name = &quot;first_name&quot;)
      private String firstName;
  
      @Column(name = &quot;last_name&quot;)
      private String lastName;
  
      @Column(name = &quot;email&quot;)
      private String email;
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public Customer() {
  
      }
  
      public Customer(String firstName, String lastName, String email) {
          this.firstName = firstName;
          this.lastName = lastName;
          this.email = email;
      }
  
      @Override
      public String toString() {
          return &quot;Customer [id=&quot; + id + &quot;, firstName=&quot; + firstName + &quot;, lastName=&quot; + lastName + &quot;, email=&quot; + email + &quot;]&quot;;
      }
  
  }
  
  </code></pre>
  <p>DAO Setup:</p>
  <pre><code>package com.ishwor.crm.DAO;
  
  import java.util.List;
  
  import com.ishwor.crm.entity.Customer;
  
  public interface CustomerDAO {
      public List&lt;Customer&gt; getCustomer();
  
  }
  </code></pre>
  <p>DAOImpl setup</p>
  <pre><code>  package com.ishwor.crm.DAOImpl;
      
      import java.util.List;
      
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;
      import org.hibernate.query.Query;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.beans.factory.annotation.Qualifier;
      import org.springframework.stereotype.Repository;
      import org.springframework.transaction.annotation.Transactional;
      
      import com.ishwor.crm.DAO.CustomerDAO;
      import com.ishwor.crm.entity.Customer;
      
      @Repository
      public class CustomerDAOImpl implements CustomerDAO {
          @Autowired
          @Qualifier(&quot;sessionFactory&quot;)
          private SessionFactory sessionFactory;
      
          public CustomerDAOImpl() {
      
          }
      
          @Override
          @Transactional
          public List&lt;Customer&gt; getCustomer() {
              // get current hibernate Session
              Session currenSession = sessionFactory.getCurrentSession();
              // create Query
              Query&lt;Customer&gt; myQuery = currenSession.createQuery(&quot;from customer&quot;, Customer.class);
              // execute query and get result
      
              return myQuery.getResultList();
          }
      }
  </code></pre>
  <p>But Using this DAO as Autowired show the Error I have following customerController setup:</p>
  <pre><code> package com.ishwor.crm.controller;
      
      import java.util.List;
      
      import org.apache.log4j.Logger;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Controller;
      import org.springframework.ui.Model;
      import org.springframework.web.bind.annotation.RequestMapping;
      
      import com.ishwor.crm.DAO.CustomerDAO;
      import com.ishwor.crm.entity.Customer;
      
      @Controller()
      @RequestMapping(&quot;/customer&quot;)
      public class CustomerController {
      
          public static Logger logger = Logger.getLogger(CustomerController.class);
      
          // Autowired customerDAO
          @Autowired
          private CustomerDAO customerDAO;
          
          
          @RequestMapping(&quot;/list&quot;)
          public String customerHome(Model model) {
              logger.info(&quot;customer index metho browsed&quot;);
      
              List&lt;Customer&gt; customer = customerDAO.getCustomer();
              
              model.addAttribute(&quot;customer&quot;, customer);
      
              return &quot;/customer/index&quot;;
          }
      }
  </code></pre>
  <p><strong>Note</strong> Without autowiring on controller class code working fine.
  Should I Used the @service annotation using other one more class and interface in order to this work .</p>