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

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/

Note: unless you need this to run as part of your CI build, you’ll need to remove this code when you’re finished debugging

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)