Access to h2 web console while running junit test in a Spring application

前端 未结 3 2011
清歌不尽
清歌不尽 2020-12-14 02:50

I\'m building a Spring application and I need to inspect my H2 in-memory database while I\'m running my JUnit tests from a web browser.

In my Spring configuration I

3条回答
  •  鱼传尺愫
    2020-12-14 03:28

    As this is probably going to be a test-debugging feature, you can add it at runtime with your @Before:

    import org.h2.tools.Server;
    
    /* Initialization logic here */
    
    @BeforeAll
    public void initTest() throws SQLException {
        Server.createWebServer("-web", "-webAllowOthers", "-webPort", "8082")
        .start();
    }
    

    And then connect to http://localhost:8082/

提交回复
热议问题