问题描述 :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘employeeController’: Unsatisfied dependency expressed through field ‘employeeDao’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.jinyu.dao.EmployeeDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
一般配置文件出了问题
看spring配置文件是否写了
开启注解扫描
<context:component-scan base-package=“com.jinyu”></context:component-scan>
或看扫描的层是否加了标识
dao层下 @Repository
service层下 @Service
controller层下 @Controller
这次错误出现就是dao层下我写成了@ResponseBody 但我一直去怀疑配置文件的问题,导致浪费很长时间