配置ssm项目报错:No qualifying bean of type ... found for dependency ...expected at least 1 bean which

配置ssm项目时,提示提示在service层注入出错,出错信息如下:大致的错误信息为:

cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘studentController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘studentServiceImpl’: Unsatisfied dependency expressed through field ‘studentMapper’: No qualifying bean of type [com.csair.student.dao.StudentMapper] found for dependency [com.csair.student.dao.StudentMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:

配置ssm项目报错:No qualifying bean of type ... found for dependency ...expected at least 1 bean which_第1张图片

 从中可以看出主要错误是注入时出错,这里注入的时mybatis generator自动生成的接口,网上的答案一般是mapping.xml中的namespace和实际的对应不上,可能字母拼写错误之类的,这个确实是常见的错误,以前我也犯过,但是我仔细核对发现并没错,后来找了很久,发现在web.xml里没有加载spring和mybatis整合的配置文件spring-mybatis.xml,加入后问题解决。

总结:这类问题的原因基本都是一些细节问题,以后遇到可以从这方面入手慢慢检查,拼写错误、配置文件未加载等等。

你可能感兴趣的:(配置ssm项目报错:No qualifying bean of type ... found for dependency ...expected at least 1 bean which)