Error creating bean with name 'XXX': Injection of autowired dependencies failed解决办法
使用SpringMVC框架,这条完整的error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘accountCtrl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bing.mapper.wxcms.service.AccountService com.bing.mapper.wxcms.ctrl.AccountCtrl.accountService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bing.mapper.wxcms.service.AccountService] 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)}
报错中异常为NoSuchBeanDefinitionException,指出没有找到要注入的内容(service或dao),从两方面着手:
1、检查下在spring配置中,是否将对应的包加入扫描。
dao配置:
扫描service包下所有使用注解的类型
2、检查对应的注解有没有加上,可能没加@service
@Service
public class AccountServiceImpl implements AccountService {
@Autowired
private AccountDao accountDao;
public List<Account> listForPage(Account searchEntity) \{
return accountDao.listForPage(searchEntity);
\}
}
-——————————
作者:夏日踩冰
来源:CSDN
原文:https://blog.csdn.net/a411358606/article/details/54426424
还没有评论,来说两句吧...