来自控制台的错误
SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeController': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ram.service.EmployeeService com.ram.controller.EmployeeController.employeeService;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeService': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ram.dao.EmployeeDao com.ram.service.EmployeeServiceImpl.employeeDao;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeDao': Injection of autowired dependencies failed;
EmployeeController.java
@Controller
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
@Qualifier(value="employeeService")
public void setEmployeeService(EmployeeService employeeService){
this.employeeService = employeeService;
}
@RequestMapping(value = "/employees", method = RequestMethod.GET)
public String listEmployee(Model model) {
model.addAttribute("employee", new Employee());
model.addAttribute("listEmployee", employeeService.listEmployee());
return "employee";
}
答案 0 :(得分:0)
此行最符合日志。不幸的是,日志不完整,因此不清楚EmployeeDao
的哪个属性丢失了:
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeDao': Injection of autowired dependencies failed;
您要将哪些字段映射到EmployeeDao
?因为其中一个找不到,可能没有用@Component
标记?