启动注解修改为 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 注:@Test 引包路径 import org.junit.jupiter.api.Test; @Test