在类的上方添加两个注解 @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SPAppLication.class )//这里是启动类