Java 创建名为employeeController的bean时出错。自动连接依赖项的注入失败。无法自动关联字段

Java 创建名为employeeController的bean时出错。自动连接依赖项的注入失败。无法自动关联字段,java,spring,hibernate,Java,Spring,Hibernate,控制台出错 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.fact

控制台出错

 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";
    }

这一行是日志中最重要的一行。不幸的是,日志不完整,因此不清楚
EmployeeDao
的哪个属性缺失:

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeDao': Injection of autowired dependencies failed;

您将哪些字段映射到
EmployeeDao
?由于其中一个无法找到,可能没有标记为
@Component

问题是由
employeeService
bean引起的,Spring的实例化失败,因为没有使用
EmployeeDao
类声明bean。您应该显示
EmployeeService
EmployeeDao
类,以及可能使用的Spring配置。可能您在EmployeeService和EmployeeDao中缺少@Component注释,以便让Spring知道它们。我使用了@Repository for employeeDaoImplNo,而不是
EmployeeDaoImpl
。。。在任何
employeedaimpl
autowires的内容上。它需要什么?你能把这门课加到你的问题里吗?