应该是你spring上下文没有注入导致的加上@RunWith(SpringJUnit4ClassRunner.class),让测试运行于spring测试环境不明白的话看这里:https://www.cnblogs.com/expiator/p/8276524.html