springboot使用junit测试时, 启动整个spring 容器

时间:2025-03-23 12:15:48

1.添加依赖

<dependency>
    <groupId></groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

2.测试类上增加注解,classes后面跟的是测试类的类名

@RunWith()
@SpringBootTest(classes = )