[Solved] ssm Error: Error creating bean with name ‘employeeController’: Injection of autowired dependencies failed

08-Dec-2021 12:08:06.572 Warning [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean 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.lyq.ssm.service.EmployeeService com.lyq.ssm.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.lyq.ssm.dao.EmployeeMapper com.lyq.ssm.service.EmployeeService.employeeMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.lyq.ssm.dao.EmployeeMapper] 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)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)

1.Scanning whether the annotation is open
Opened

<context:component-scan base-package="com.lyq.ssm">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:exclude-filter>
</context:component-scan>

2. Whether spring listener is configured
if it is not configured:

    <!--Configure spring's listener to load only the files in the WEB-INFO directory by default-->
<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

After the configuration is completed, it runs successfully

Read More: