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" 即可