I am trying to add the H2 console to my Quarkus application using Java 21 and Gradle with kotlin DSL.
I have looked at this stackoverflow article from a while back but when I add the quarkus-undertow
dependency I get a compile “unsupported java” error.
How can I get this working?
I added my code to github repo and also outline the code below.
I am using gradle and added the following dependencies:
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("io.quarkus:quarkus-hibernate-orm")
implementation("io.quarkus:quarkus-jdbc-h2")
implementation("io.quarkus:quarkus-arc")
// The following 2 dependencies is what I read up on should be added to view the console.
implementation("io.quarkus:quarkus-vertx")
implementation("io.quarkus:quarkus-undertow")
}
I also added a src/resources/META-INF/web.xml
with:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4.0.xsd"
version="4.0">
<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>
And my application.properties look like:
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:file:../src/main/resources/data/database;AUTO_SERVER=true;DB_CLOSE_DELAY=-1
quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.log.sql=true
quarkus.datasource.jdbc.username=sa
quarkus.datasource.jdbc.password=sa