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

前端 未结 3 2000
清歌不尽
清歌不尽 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:21

    I guess the problem is that you are connecting to h2db directly from your application. Not through the server you are launching with bean. Because of this your app and h2db-web-interface can't share one in-memory database.

    You should change jdbcUrl in tests to something like jdbc:h2:tcp://localhost/mem:my_DB;DB_CLOSE_DELAY=-1;MODE=Oracle and in browser you should connect to the same url.

    With jdbc urls like jdbc:h2:tcp://localhost/... all connections will go through the h2db-server and you can view database state in browser.

提交回复
热议问题