问题:org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'ljh.dao.EmployeeDao' available: expected at least 1 bean which qualifies as autowire candidate.
解决方法:依赖至少有一个备选的bean能被自动注入
(1)检查该bean是否加到ioc容器中
<!-- 配置扫描器,将mybatis接口的实现加入到ioc容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="ljh.dao"></property>
</bean>
(2)看是否看开启注解扫描
<context:component-scan base-package="ljh"/>
(3)看该接口上是否加注解
@Repository
(4)通过上下文看是否能获得这个bean
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/applicationContext.xml");
Object employeeDao = context.getBean("employeeDao");