我的原因是SpringContextUtils.getBean(XXX),getBean的目标类没加注解,所以没被扫描到报空指针的错误。 在目标类上加上注解(我的是mapper上加上@Mapper)就好了