Error creating bean with name

706 阅读1分钟

junit测试报错 Error creating bean with name ‘ssh_01.TestDao\创建ssh_01.TestDao失败

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ssh_01.TestDao’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [Dao.ExamPaperDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, type=class java.lang.Object, authenticationType=CONTAINER, lookup=, description=, name=)}
at

1. 可能是注解没有加上,spring注解需要开启扫描,变成实例化组件,可能是dao接口的实体类没有加注解,或者没有填写实体类名(注解小括号中的value没有赋值,括号中只有名称自动识别为value) 2. 配置文件中的路径出现了错误,springxml,配置中如果开启组件扫描的时候路径写错,实体类工厂创建对象的时候也会产生错误