加了@SpringBootTest和@Test还是报空指针异常 原因 @Test导入的包不对 原来是 import org.junit.Test; 看到@Test直接点回车了,根本没注意。。。。 修改后 import org.junit.jupiter.api.Test; 参考