spring 全注解 扫包问题

来源:互联网 发布:java方法里面调用方法 编辑:程序博客网 时间:2024/04/30 06:22

 Error creating bean with name 'roleController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.rails.espm.core.service.RoleService cn.rails.espm.core.controller.system.RoleController.roleService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.rails.espm.core.dao.RoleDao cn.rails.espm.core.service.serviceImpl.RoleServiceImpl.roleDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDao' defined in file [D:\apache-tomcat-7.0.68\webapps\ESPM\WEB-INF\classes\cn\rails\espm\core\dao\daoImpl\RoleDaoImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required


问题挺有意思,解决方案也挺有意思 配置文件中  <beans xmlns=..... default-autowire="byName">


如果你的service 及dao中 @Service("userService") 等 没问题 加上 default-autowire="byName" 即可

0 0