SpringBoot自动创建后,test 中没有 @RunWith(SpringRunner.class)注解。
@SpringBootTest
class Chapter2ApplicationTests {
@Test
void contextLoads() {
}
}
解决方法:在pom.xml中添加 junit 依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>