@SpringBootTest 相关理解 基础知识 首先 查文档 再百度

@SpringBootTest

springboot 文档内容:

Spring Boot提供了一个@SpringBootTest注释,spring-test @ContextConfiguration当您需要Spring Boot功能时,它可以用作标准注释的替代方法。注释的工作原理是通过 创建 ApplicationContext测试中使用的SpringApplication。除了 @SpringBootTest提供许多其他注释之外,还提供了用于 测试应用程序的更具体的切片。

如果您使用的是JUnit 4,请不要忘记添加@RunWith(SpringRunner.class)到测试中,否则注释将被忽略。如果您使用的是JUnit 5,则无需添加等效项@RunWith(SpringExtension),@SpringBootTest并且其他@…Test注释已经使用它进行注释。

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42664961/article/details/86567351