Tuesday, 20 August 2019

How to setup H2 web console in SpringBoot

Springboot may auto-config H2 database, once it sees the dependency in the classpath.

How to set up the H2 database virtual console in Spring boot, to show H2 tables in a browser.

Go to the resource folder,  and add the following in the property file

spring.h2.console.enabled=true

thus h2 browser console will be enabled.

You may specify h2 console path
spring.h2.console.path=/h2

otherwise, the default will be /h2-console

spring-boot will config the database driver by default
Driver class: org.h2.Driver

You need to specify the JDBC URL for the project
spring.datasource.url= jdbc:h2:file:~/dev-db

Otherwise, the default value will be
JDBC URL:  jdbc url:  jdbc:h2:~/test

It may also specify username and password
spring.datasource.usename = xxx
spring.datasource.password = yyy

link to the URL: localhost:8080/h2

you will see the login console.

Click button 'connect', it shows the database management tool in the browser.






No comments:

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...