Spring Boot在调试模式下阻止H2控制台

我正在尝试在调试模式下的WebIntegrationTest期间访问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配置如下:

 @ActiveProfiles("local,unittest") @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = MyApplication.class) @WebIntegrationTest({"spring.h2.console.enabled=true", "server.port=8080"}) public class MyResourceTest { 

如何将H2-in-memory数据库与调试模式分离?

断点可以配置为挂起整个VM或仅挂起一个线程。 在IntelliJ中,您可以通过右键单击相应的断点来设置此项。 我的断点被配置为暂停整个VM,因此每个断点也被阻止访问H2-Console。

在此处输入图像描述