求助,SpringBoot+mybatis框架搭建的问题
求助各位大佬,我搭了一个SpringBoot+mybatis的框架,目前跑的时候出现了点问题,异常提示的是Controller层里没有成功将StudentMapper注入,但是我确定注解啥的应该是都写上的,而且配置文件也应该是全的吧。。。我自己感觉是没问题的。然后我对异常一层层分析下去,最后定位到应该是在注入dao层时没有成功解析mapper.xml,最后我直接对源码进行打断点进行debug,发现是执行到这里出了问题,然后就被catch后抛出异常了 。求问大佬能不能帮我看看是不是配置文件上出的问题还是哪里的问题,我把比较关键可能出错的地方都贴一下,包括控制台的关键异常信息
先给控制台抛出的异常:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentMapper' defined in file [D:\Documents\Desktop\hjs\target\classes\com\hjs\graduation\mapper\StudentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [generatorConfig.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.NullPointerException
可能有点长,我摸索了半天最后猜测可能问题是最后出在对mapper文件的解析上,我通过对框架源码进行打断点,debug后发现当执行到源码的这个位置时抛出了异常:
下面给一下项目的架构和关键部分的代码,求各位牛客大佬分析下哪里出了错,小弟真的不胜感激,都弄了好久了55
dao层:
controller层:
SpringBoot项目入口:
application.yml配置文件:
对应dao的mapper.xml文件
项目架构: