Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Error creating bean with name 'empDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [model.Emp] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}Spring异常
有道翻译一下你就明白了:
错误创造bean与名字“empDao”:注入资源依赖性;嵌套异常org.springframework.beans.factory失败。NoSuchBeanDefinitionException:不匹配的bean类型[模型。Emp)发现的依赖:问题应该是:
spring配置文件中empDao的注入部分有问题,可能是注入empDao的时候model.Emp这个bean也没有注入的原因;或者是你用@annotation自动注入的时候,关联的bean有误,autowire无论通过byName,还是byType找不到需要引入的bean!