这是程序执行顺序的问题,spring还未对mapper注入时就被调用了。具体方法可参考这篇博客https://blog.csdn.net/kaituozhemj/article/details/111321606