As Spring boot application provides a property to set the web console URL of the H2 Database.
spring.h2.console.path=/h2
Is there a way to set this same property in the Quarkus application? If not then what is the default web console URL.
Yes, there is a way. But it's not quite as simple as in Spring Boot because Quarkus does not do the same first-class support for H2 as Spring Boot does.
First, you need to activate Servlet support in Quarkus. Then, you go ahead and configure the H2 servlet in a web.xml
deployment descriptor or in a undertow-handlers.conf
if you're familiar with it.
Here we go:
quarkus-jdbc-h2
extension addedquarkus-vertx
and quarkus-undertow
extensionssrc/main/resources/META-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Web Application</display-name>
<servlet>
<servlet-name>h2-console</servlet-name>
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>h2-console</servlet-name>
<url-pattern>/h2/*</url-pattern>
</servlet-mapping>
</web-app>
Run ./mvnw quarkus:dev
and go to http://localhost:8080/h2
where the console should show up.
If you need to set a parameter use <init-param>
like e.g.:
<servlet>
<servlet-name>h2-console</servlet-name>
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
<init-param>
<param-name>webAllowOthers</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
http://www.h2database.com/html/tutorial.html#usingH2ConsoleServlet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With