2016.11.4 Injection of autowired dependencies failed

运行项目时,提示错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseController': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.baosight.rds.kubernetes.RestDao com.baosight.rds.kubernetes.DatabaseController.dao;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.baosight.rds.kubernetes.RestDao] 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)} org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
 
这段错误的大致含义就是:
创建name为databaseController的bean时失败了。因为找不到自动注入的变量:DatabaseController.dao。
因为这个名为dao的变量,类名是RestDao,但是在RestDao里却找不到一个自动注入的qualifies(比如@Service,@Component,@Repository,@Controller这种)。
所以要解决这个问题,就是检查RestDao类,看自己到底遗漏了哪个qualifies。
 
检查后,发现RestDao没有加@Repository。
 
 
 
原文地址:https://www.cnblogs.com/lyh421/p/6053441.html