title: No qualifying bean found for dependency [**.Clients]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
body: <p>I'm trying to develop simple application using spring framework, when I execute the project at eclipse this exception : </p>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientService': Unsatisfied dependency expressed through method 'setClientDao' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [stockManagerWeb.net.alitech.stockManager.props.dao.Clients]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  May 03, 2017 11:34:23 AM org.springframework.web.context.ContextLoader initWebApplicationContext
  SEVERE: Context initialization failed
  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientService': Unsatisfied dependency expressed through method 'setClientDao' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [stockManagerWeb.net.alitech.stockManager.props.dao.Clients]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:648)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219)
      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:751)
      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:4853)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [stockManagerWeb.net.alitech.stockManager.props.dao.Clients]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1463)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1094)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1056)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
      ... 24 more
  
  May 03, 2017 11:34:23 AM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientService': Unsatisfied dependency expressed through method 'setClientDao' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [stockManagerWeb.net.alitech.stockManager.props.dao.Clients]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:648)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219)
      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:751)
      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:4853)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [stockManagerWeb.net.alitech.stockManager.props.dao.Clients]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1463)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1094)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1056)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
      ... 24 more
  </code></pre>
  
  <p><strong>Implementation:</strong></p>
  
  <p><strong>Clients:</strong></p>
  
  <pre><code>@Component("clientDao")
  public class Clients extends SqlConnectionManager {
  
      public List&lt;Client&gt; getClients() {
  
          return jdbc.query("select * from clients", new RowMapper&lt;Client&gt;() {
  
              public Client mapRow(ResultSet rs, int rowNum) throws SQLException {
                  Client client = new Client();
  
                  client.setClientId(rs.getInt("clientId"));
                  client.setClientName(rs.getString("clientName"));
                  client.setAddress(rs.getString("address"));
                  client.setEmail(rs.getString("email"));
                  client.setPhone(rs.getString("phone"));
                  client.setType(rs.getString("type"));
                  return client;
              }
  
          });
      }
  
      public List&lt;Client&gt; getClients(String clientName) {
  
          MapSqlParameterSource parameters = new MapSqlParameterSource();
  
          parameters.addValue("clientName", clientName);
          return jdbc.query(
                  "select * from clients where clientName = :clientName",
                  parameters, new RowMapper&lt;Client&gt;() {
  
                      public Client mapRow(ResultSet rs, int rowNum)
                              throws SQLException {
                          Client client = new Client();
  
                          client.setClientId(rs.getInt("clientId"));
                          client.setClientName(rs.getString("clientName"));
                          client.setAddress(rs.getString("address"));
                          client.setEmail(rs.getString("email"));
                          client.setPhone(rs.getString("phone"));
                          client.setType(rs.getString("type"));
                          return client;
                      }
  
                  });
  
      }
  
      /**
       * get client by PHONE number
       * 
       * @param phone
       * @return
       */
      public List&lt;Client&gt; getClientsByPhoneNumber(String phone) {
  
          MapSqlParameterSource parameters = new MapSqlParameterSource();
  
          parameters.addValue("phone", phone);
  
          return jdbc.query("select * from clients where phone = :phone",
                  parameters, new RowMapper&lt;Client&gt;() {
  
                      public Client mapRow(ResultSet rs, int rowNum)
                              throws SQLException {
                          Client client = new Client();
  
                          client.setClientId(rs.getInt("clientId"));
                          client.setClientName(rs.getString("clientName"));
                          client.setAddress(rs.getString("address"));
                          client.setEmail(rs.getString("email"));
                          client.setPhone(rs.getString("phone"));
                          client.setType(rs.getString("type"));
                          return client;
                      }
  
                  });
  
      }
  
      /**
       * 
       * @param client
       * @return
       */
      public boolean create(Client client) {
          BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(
                  client);
          try {
  
              return jdbc
                      .update("insert into clients (clientName, address, email, phone, type) "
                              + "values (:clientName, :address, :email, :phone, :type)",
                              params) == 1;
          } catch (InvalidDataAccessApiUsageException e) {
              e.printStackTrace();
          }
  
          return false;
  
      }
  
  
      /**
       * get client by his phone number
       * @param phone
       * @return
       */
      public Client getClient(String phone) {
          MapSqlParameterSource parameters = new MapSqlParameterSource();
          parameters.addValue("phone", phone);
          return jdbc.queryForObject(
                  "select * from clients where phone = :phone", parameters,
                  new RowMapper&lt;Client&gt;() {
  
                      public Client mapRow(ResultSet rs, int rowNum)
                              throws SQLException {
                          Client client = new Client();
                          client.setClientId(rs.getInt("clientId"));
                          client.setClientName(rs.getString("clientName"));
                          client.setAddress(rs.getString("address"));
                          client.setEmail(rs.getString("email"));
                          client.setPhone(rs.getString("phone"));
                          client.setType(rs.getString("type"));
  
                          return client;
                      }
                  });
      }
  
      @Transactional
      public int[] create(List&lt;Client&gt; clients) {
          SqlParameterSource[] params = SqlParameterSourceUtils
                  .createBatch(clients.toArray());
  
          return jdbc.batchUpdate(
                          "insert into clients (clientName,  address, email, phone, type) "
                                  + "values (:clientName,  :address, :email, :phone, :type)",
                          params);
      }
  
  }
  </code></pre>
  
  <p><strong>ClientService:</strong></p>
  
  <pre><code>@Service
  public class ClientService {
  
      private Clients clientDao;
  
      @Autowired
      public void setClientDao(Clients clientDao){
          this.clientDao = clientDao;
      }
  
      public void addClient(Client client) {
          clientDao.create(client);
      }
  
  }
  </code></pre>
  
  <p><strong>ClientController:</strong></p>
  
  <pre><code>@Controller
  public class ClientController {
  
  
      private ClientService clientService;
  
      @Autowired
      public void setService(ClientService service) {
          this.clientService = service;
      }
  
  
  
      @RequestMapping(value = "/doAddClient", method = RequestMethod.POST)
      public String doAddClient(@Valid Client client ){
          clientService.addClient(client);
  
  
          return "order";
      }
  
  }
  </code></pre>
  
  <p><strong>pom.xml:</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;net.ali.taha&lt;/groupId&gt;
      &lt;artifactId&gt;stockManagerWeb&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
      &lt;build&gt;
          &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.4&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
              &lt;version&gt;4.2.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
              &lt;version&gt;4.2.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
              &lt;version&gt;4.2.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.integration&lt;/groupId&gt;
              &lt;artifactId&gt;spring-integration-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.7.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.validation&lt;/groupId&gt;
              &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
              &lt;version&gt;1.1.0.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.39&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
              &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
              &lt;version&gt;1.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;jstl&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.1.4.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
              &lt;version&gt;5.2.4.Final&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>Configuration files:</strong> 
  <strong>beans.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"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"&gt;
  
      &lt;context:component-scan base-package="stockManager"&gt;
      &lt;/context:component-scan&gt;
  
  
      &lt;context:property-placeholder
          location="stockManager/props/jdbc.properties" /&gt;
  
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close"&gt;
  
          &lt;property name="driverClassName" value="${jdbc.driver}"&gt;&lt;/property&gt;
          &lt;property name="url" value="${jdbc.url}"&gt;&lt;/property&gt;
          &lt;property name="password" value="${jdbc.password}"&gt;&lt;/property&gt;
          &lt;property name="username" value="${jdbc.username}"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>dao-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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee"
      xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"&gt;
  
  
      &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
      &lt;context:component-scan base-package="stockManager.props.dao"&gt;
      &lt;/context:component-scan&gt;
      &lt;jee:jndi-lookup jndi-name="jdbc/spring" id="dataSource"
          expected-type="javax.sql.DataSource"&gt;
      &lt;/jee:jndi-lookup&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>security-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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
      xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
  
  
  
      &lt;security:authentication-manager&gt;
          &lt;security:authentication-provider
              user-service-ref="userDetailsService" /&gt;
  
      &lt;/security:authentication-manager&gt;
  
      &lt;security:http use-expressions="true" auto-config="true"&gt;
          &lt;security:logout logout-success-url="/login"
              invalidate-session="true" logout-url="/logout" /&gt;
          &lt;security:intercept-url pattern="/dashboard"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/login"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/addProduct"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/doAddProduct"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/productsList"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/doOrder"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/cart"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/orderDetails"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/addToCart"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/addMoreToCart"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/getOrdersHistory"
              access="isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/cancelOrder"
              access="isAuthenticated()" /&gt;
  
  
          &lt;security:intercept-url pattern="/users"
              access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/stockManagerWeb"
              access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/" access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/static/**"
              access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/login"
              access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/logoutSuccess"
              access="permitAll" /&gt;
          &lt;security:form-login login-page="/login"
              default-target-url="/dashboard" login-processing-url="/j_spring_security_check"
              authentication-failure-url="/login?error" username-parameter="username"
              password-parameter="password" /&gt;
          &lt;security:session-management&gt;
              &lt;security:concurrency-control
                  max-sessions="5" expired-url="/login" /&gt;
          &lt;/security:session-management&gt;
  
  
      &lt;/security:http&gt;
  
      &lt;bean id="userDetailsService" class="stockManagerWeb.net.alitech.stockManager.beans.UserDetailsServiceImpl" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>service-context:</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"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"&gt;
  
  
      &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
      &lt;context:component-scan
          base-package="stockManagerWeb.net.alitech.service"&gt;
      &lt;/context:component-scan&gt;
      &lt;mvc:resources mapping="/css/**" location="/css/" /&gt;
      &lt;mvc:resources mapping="/images/**" location="/images/" /&gt;
      &lt;mvc:resources mapping="/js/**" location="/js/" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Thanks for help.</p>