title: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController':
body: <p>I am getting below error while creating a spring maven rest services:</p>
  
  <pre><code>WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'jdbcUserDAO': No qualifying bean of type [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO] found for dependency [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO] found for dependency [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  Jan 05, 2019 6:17:28 PM org.springframework.web.context.ContextLoader initWebApplicationContext
  SEVERE: Context initialization failed
  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'jdbcUserDAO': No qualifying bean of type [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO] found for dependency [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO] found for dependency [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:350)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4840)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO] found for dependency [com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1398)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1018)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:570)
      ... 24 more
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p><strong>UserController.java</strong></p>
  
  <pre><code>@RestController
  public class UserController {
      @Autowired
      private JdbcUserDAO jdbcUserDAO;    
      @RequestMapping("/")
      @ResponseBody
      public String welcome() {
          return "Welcome to RestTemplate Example.";
      }
  }
  </code></pre>
  
  <p><strong>UserDAO.java</strong></p>
  
  <pre><code>public interface UserDAO {
      public List&lt;User&gt; getAllUsers();
  }
  </code></pre>
  
  <p><strong>jdbcUserDAo.java</strong></p>
  
  <pre><code>public class JdbcUserDAO implements UserDAO {
  
      DataSource dataSource;  
      public void setDataSource(DataSource dataSource) {
          this.dataSource = dataSource;
      }
      @Override
      public List&lt;User&gt; getAllUsers() {
          String sql = "select * from customer";
          JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
          System.out.println("getJdbcTemplate() "+jdbcTemplate);
          List&lt;User&gt; userList = jdbcTemplate.query(sql, new UserMapper());
          return userList;
      }
  }
  </code></pre>
  
  <p><strong>ApplicationConfiguration.java</strong></p>
  
  <pre><code>@ComponentScan(basePackages = {"com.ganeshTrading.riceAppService"})
  @Configuration
  @EnableWebMvc
  public class ApplicationConfiguration {
  }
  </code></pre>
  
  <p><strong>servlet-context.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" 
  xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation=" http://www.springframework.org/schema/beans  
   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-4.3.xsd"&gt;
  
  
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.ganeshTrading.riceAppService" /&gt;
  &lt;import resource="classpath:/application-config.xml" /&gt; 
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>application-config.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  
  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-4.3.xsd"&gt;
  
  
      &lt;bean id="jdbcUserDAO" class="com.ganeshTrading.riceAppService.dao.impl.JdbcUserDAO"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
   &lt;!--   &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;     --&gt;
  
     &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/****"&gt;&lt;/property&gt;
      &lt;property name="username" value="***"&gt;&lt;/property&gt;
      &lt;property name="password" value="***"&gt;&lt;/property&gt;
     &lt;/bean&gt;
  
  
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app xmlns:xsi="w3.org/2001/XMLSchema-instance" xmlns="xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="xmlns.jcp.org/xml/ns/javaee xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
        &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Please advise what is wrong in my code. Thanks in advance.</p>