H2-console in r2dbc-h2 driver
Asked Answered
C

2

6

I am using R2DBC-H2 driver, and my UR.L is spring.r2dbc.url=r2dbc:h2:mem:///customer

Using this configuration, SpringBoot starts fine, however, I can not access the h2-console.

Does anybody know why, and how I can fix it?

Cermet answered 14/7, 2020 at 21:16 Comment(2)
Do you get an error message that you can share? Please read How to Ask.Lubet
I'm not getting access to the h2 console with r2dbc-h2 driver, as wellLingonberry
T
1

H2 Console depends on traditional JDBC drivers, not compatible with the Spring WebFlux stack.

If you are developing a WebFlux application, you can use H2 as a standalone database, and use H2 Console freely.

  1. Following the official Getting Started guide to start H2 Database and H2 Console.
  2. Set your spring.r2dbc.url to the database URL you are running in the first step.

NOTE: Do not use a Memory DB here.

Tarbes answered 8/2, 2023 at 3:8 Comment(0)
L
0

If I understand the source code of H2ConsoleAutoConfiguration correctly, the h2 console auto configuration from spring boot does not work in a reactive environment.

...
@ConditionalOnWebApplication(type = Type.SERVLET)
...
public class H2ConsoleAutoConfiguration {

You can confirm this by yourself by changing the type of your web application to SERVLET (for example, by adding spring-boot-starter-web as a dependency) which will activate the route to the h2 console (if enabled in the application properties). The h2-console route endpoint will start working again.

As the whole code seems very servlet-specific, I don't know how to properly fix this problem.

Lubet answered 15/10, 2020 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.