micronaut-projects/micronaut-core

H2 Web Client Support

Opened this issue · 7 comments

During the development of a Micronaut application with H2, It would be great if we can check the data in the H2 database using a web client.

In Spring Boot, we could do this to enable H2 Console. spring.h2.console.enabled=true

While this looks likes a trivial feature from a production standpoint, it is important for beginning developers starting with Micronaut.

Current web console seems quite tied to servlet API, we will see what we can do

Any update on this feature?

No update. Currently the console which is provided by H2 is a servlet, which makes it challenging to support

any update?

Nope, if someone wants to contribute an implementation of H2Servlet then contributions welcome

Could be made to work in the Servlet runtime. See https://github.com/micronaut-projects/micronaut-servlet

Quick & dirty & old & easy solution:

First, change h2 maven dependency scope from runtime to compile an then
you will be able to start h2 web console programatically

package com.woorea;

import io.micronaut.runtime.Micronaut;
import org.h2.tools.Server;

public class Application {
  public static void main(String[] args) throws Exception {
    Server.createWebServer().start();
    Micronaut.run(Application.class);
  }
}

You can access localhost:8082 to see your mem db ;)

Note: you can change port using -webPort flag