Spring Boot 在调试模式下阻塞了 H2 控制台
2022-09-02 20:34:04
我正在尝试在调试模式下的 Web 集成测试期间访问 H2 控制台。但是,我注意到Spring Boot在调试测试时阻止了H2控制台。似乎一旦到达断点,H2控制台也会被阻止。我正在使用Spring Boot 1.3.1.RELEASE。
以下测试中的每个断点都会导致 H2 控制台阻塞。在断点 1 中,将显示登录页。然后我按下登录按钮,但在我让测试到下一个断点之前没有任何反应。在断点 2 中,我已登录并可以执行查询。但只有当我转到下一个断点时,才会显示查询结果。
@Test
public void whenGetById_thenCorrectId() throws InterruptedException {
// do some stuff
// breakpoint 1
Thread.sleep(1000);
// breakpoint 2
Thread.sleep(1000);
// breakpoint 3
}
WebIntegrationTest ist 的配置如下:
@ActiveProfiles("local,unittest")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebIntegrationTest({"spring.h2.console.enabled=true", "server.port=8080"})
public class MyResourceTest {
如何将内存中的 H2 数据库与调试模式分离?