Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
上述报错提示:Java中的空指针异常引起的。具体原因为在StudentController的selectByPage方法中,在调用MyBatis plus框架的查询方法时,其中使用了自定义的MPJAbstractLambdaWrapper类,但该类的getCache方法使用不当导致NullPointerException异常。解决方法是检查MPJAbstractLambdaWrapper类的实现并修复其中getCache方法的问题。
主要是:.select(Class::getClassName)为空值
解决过程:因为我其他都可以就是这一个类是报错的!我觉得我实体类、映射方法都没有问题,百度上面的各种解决方法都是少了@RestController,@Service,@Mapper等等注释,或者是映射问题。
结果:经过多次调试和查询问题,我觉得是数据表的问题,最后发现因为生成实体类getter方法会变成getClassName():?string,会和我的命名冲突!!!class_name 即可以表示班级名称,也有类名的意思。
最后我把数据库名和字段名都改了,结果就正常了