错误o.s.b.d.LoggingFailureAnalysisReporter和Invalid bound statement (not found)

o.s.b.d.LoggingFailureAnalysisReporter
第一:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.

Description:
Field employeeDao in com.jun.managementsystem.controller.EmployeeController required a bean of type ‘com.jun.managementsystem.dao.EmployeeDao’ that could not be found.

The injection point has the following annotations:
@org.springframework.beans.factory.annotation.Autowired(required=true)

Action:
Consider defining a bean of type ‘com.jun.managementsystem.dao.EmployeeDao’ in your configuration.

大概的意思是@Autowired注解没有注解成功,因为它没有找到相关类型的bean,@Autowired注入是type类型注入的,是我自己忘记在dao层或者mapper层没有添加组件注解@Repository或者@Component也可以,但最好使用@Repository。

如果是控制层或者业务层则是@Controller或者@Service.

Invalid bound statement (not found)
第二:映射配置错误,mapper文件扫描不到或者信息错误
这个错误主要是漏了某点或者忘记写错字母等引起的,错误原因多种多样,但都集中在配置mapper.xml文件和路径上。

检查namespace是否正确
dao层与配置xml文件是否对应
resultType是否用了别名却没设置(我就是忘记了这点)
resultMap是否一一对应
最后则是mapper的XML配置路径是否正确,特别是文件创建的坑,要一个一个创建,用点的话其实是一个目录,可以去项目代码位置查看一下是否正确。

猜你喜欢

转载自blog.csdn.net/qq_44961149/article/details/105866783