title: No qualifying bean of type [...] found for dependency [...]: expected at least 1 or……
body: <p>I was doing the project when you encounter a problem in the platform to find a solution can not be resolved, I would like to use MapperScannerConfigurer, to automatically scan my Dao layer files, but failed, the following is my code and error messages</p>
  
  <p>Configuration.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd"&gt;
  &lt;configuration&gt;
  &lt;typeAliases&gt;
      &lt;typeAlias alias="City" type="org.zhangzx.mybatis.demo.model.City" /&gt;
  &lt;/typeAliases&gt;
  </code></pre>
  
  <p></p>
  
  <p>City.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;
  
  &lt;mapper namespace="org.zhangzx.mybatis.demo.dao.CityDao"&gt;
  &lt;select id="getCityFromName" parameterType="string" resultType="City"&gt;
      select* from citys where city_name = #{city_name}
  &lt;/select&gt;
  &lt;select id="selectCitys" parameterType="string" resultMap="cityList"&gt;
      select * from citys where city_province = #{province}
  &lt;/select&gt;
  
  &lt;insert id="addCity" parameterType="City"  useGeneratedKeys="true"     keyProperty="id"&gt;
      insert into citys values(2333333,#{city_code},#{city_name},#{city_name_eg},#{city_province})
  &lt;/insert&gt;
  
  &lt;resultMap type="City" id="cityList"&gt;
      &lt;id column="city_id" property="city_id" /&gt;
      &lt;result column="city_code" property="city_code" /&gt;
      &lt;result column="city_name" property="city_name" /&gt;
      &lt;result column="city_name_eg" property="city_name_eg" /&gt;
      &lt;result column="city_province" property="city_province" /&gt;
  &lt;/resultMap&gt;
  &lt;/mapper&gt;
  </code></pre>
  
  <p>CityDao.java file</p>
  
  <pre><code>public interface CityDao {
  
  public City getCityFromName(String city_name);
  
  public List&lt;City&gt; selectCitys(String province);
  
  public void addCity(City city);
  }
  </code></pre>
  
  <p>CityController.java </p>
  
  <pre><code>@Controller
  public class CityController {
  @Autowired
  CityDao cityDao;
  
  @RequestMapping(value="/list", method=RequestMethod.GET)
  public ModelAndView listAllCitys(ModelMap model){
      List&lt;City&gt; citys=cityDao.selectCitys("广东");
      model.addAttribute("citys",citys);
      return new ModelAndView("carlist","citys",citys);
  }
  }
  </code></pre>
  
  <p>Beans.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:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx" 
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:p="http://www.springframework.org/schema/p"
  xsi:schemaLocation="  
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd  
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd  
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
  default-autowire="byName" default-lazy-init="false"&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;!-- 自动装配一定要 加上此片段 --&gt;
  &lt;context:component-scan base-package="org.zhangzx.mybatis.demo" /&gt;
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url"
          value="jdbc:mysql://localhost:3306/weather_db?useSSL=false" /&gt;
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="admin" /&gt;
  &lt;/bean&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="configLocation" value="Configuration.xml" /&gt;
      &lt;property name="mapperLocations"
          value="classpath*:org/zhangzx/mybatis/demo/mapper/*.xml" /&gt;
  
  &lt;/bean&gt; 
  &lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt;
      &lt;property name="basePackage" value="org.zhangzx.mybatis.demo.dao" /&gt;
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>the error meaasge</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cityController': Unsatisfied dependency expressed through field 'cityDao': No qualifying bean of type [org.zhangzx.mybatis.demo.dao.CityDao] found for dependency [org.zhangzx.mybatis.demo.dao.CityDao]: 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 [org.zhangzx.mybatis.demo.dao.CityDao] found for dependency [org.zhangzx.mybatis.demo.dao.CityDao]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
  org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)
  org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
  org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
  org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
  org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
  org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
  org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
  org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
  org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
  javax.servlet.GenericServlet.init(GenericServlet.java:158)
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
  org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
  org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
  org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
  java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  java.lang.Thread.run(Unknown Source)
  </code></pre>