title: Spring MyBatis expected at least 1 bean which qualifies as autowire candidate for this dependency
body: <p>i have a trouble with my Spring MyBatis Project.
  Here the classes of the 4 packages tiers:
  controller
  mapper
  model
  service</p>
  
  <p>com.mb.alf.controller</p>
  
  <p>ServizioController.java</p>
  
  <pre><code>package com.mb.alf.controller;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.SessionAttributes;
  import org.springframework.web.servlet.ModelAndView;
  import com.mb.alf.model.Servizio;
  import com.mb.alf.service.ServizioService;
  
  @Controller
  @SessionAttributes("servizio")
  public class ServizioController {
  
      @Autowired
      private ServizioService servizioService;
  
      @RequestMapping("/returnServizio")
      public ModelAndView returnServizio() {
          Servizio servizio = servizioService.getServizio();
          return new ModelAndView("returnServizio", "servizio", servizio);    }}
  </code></pre>
  
  <p>com.mb.alf.mapper</p>
  
  <p>ServizioMapper.java</p>
  
  <pre><code>package com.mb.alf.mapper;
  import org.apache.ibatis.annotations.Select;
  import com.mb.alf.model.Servizio;
  
  public interface ServizioMapper {
  
      @Select("select s.ser_puntopresa, s.ser_oldcodser from serviz s where s.ser_ute = '01' and S.SER_PUNTOPRESA = 101")
        public   Servizio  getServizio();
  }
  </code></pre>
  
  <p>com.mb.alf.model</p>
  
  <p>Servizio.java</p>
  
  <pre><code>package com.mb.alf.model;
  
  public class Servizio {
       Integer serv_puntopresa;
       Integer ser_oldcodser;
  
      public Integer getSer_oldcodser() {
          return ser_oldcodser;   }
  
      public void setSer_oldcodser(Integer ser_oldcodser) {
          this.ser_oldcodser = ser_oldcodser; }
  
      public Integer getServ_puntopresa() {
          return serv_puntopresa;    }
  
      public void setServ_puntopresa(Integer num) {
          this.serv_puntopresa = num;    }
  }
  </code></pre>
  
  <p>com.mb.alf.service</p>
  
  <p>ServizioService.java</p>
  
  <pre><code>package com.mb.alf.service;
  import com.mb.alf.model.Servizio;
  
  public interface ServizioService {
  
      Servizio  getServizio();    
      }
  </code></pre>
  
  <p>ServizioServiceImpl.java    </p>
  
  <pre><code>package com.mb.alf.service;
  import org.springframework.beans.factory.annotation.Autowired; 
  import org.springframework.stereotype.Component; 
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  import com.mb.alf.mapper.ServizioMapper; 
  import com.mb.alf.model.Servizio;
  
  @Component @Service("servizioService") 
  public class ServizioServiceImpl implements  ServizioService {
  
       @Autowired       
       private ServizioMapper   servizioMapper;
  
       @Transactional     
       public Servizio getServizio() {                
          return servizioMapper.getServizio();    }   }
  </code></pre>
  
  <p>Here my XML files:</p>
  
  <p>web.xml</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
  &lt;servlet&gt;
    &lt;servlet-name&gt;myBatisServlet&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/config/springConfig.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;myBatisServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
    &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>springConfig.xml </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"
    xmlns:tx="http://www.springframework.org/schema/tx"
    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/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"&gt;
  
  &lt;mvc:annotation-driven /&gt;
  &lt;context:component-scan base-package="com.mb.alf" /&gt;
  
  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
    &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
    &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/&gt;
          &lt;property name="url" value="jdbc:oracle:thin:@MYHOST:orcl"/&gt;
          &lt;property name="username" value="USER"/&gt;
          &lt;property name="password" value="PASSWORD"/&gt;
      &lt;/bean&gt;  
  
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;property name="typeAliasesPackage" value="com.mb.alf.model"/&gt;
    &lt;property name="mapperLocations" value="classpath*:com/mb/alf/mapper/*.xml" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"&gt;
    &lt;constructor-arg index="0" ref="sqlSessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt;
    &lt;property name="basePackage" value="com.mb.alf.mappers" /&gt;
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>It gets this Exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servizioController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mb.alf.service.ServizioService com.mb.alf.controller.ServizioController.servizioService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servizioService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mb.alf.mapper.ServizioMapper com.mb.alf.service.ServizioServiceImpl.servizioMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mb.alf.mapper.ServizioMapper] 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>
  
  <p>Please, how and where  can I implement the correct bean?</p>
  
  <p>Thanks in advance</p>