更新时间:2023-01-18 17:42:18
是的,有一种方法.但这并不像Spring Boot中那么简单,因为Quarkus对Spring H2的一流支持不如Spring Boot.
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.
首先,您需要激活Quarkus中的Servlet支持.然后,继续进行操作,并在web.xml
部署描述符中或如果您熟悉的话在undertow-handlers.conf
中配置H2 servlet.
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.
我们在这里:
quarkus-jdbc-h2
扩展名quarkus-vertx
和quarkus-undertow
扩展名src/main/resources/META-INF/web.xml
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>
运行./mvnw quarkus:dev
并转到显示控制台的http://localhost:8080/h2
.
Run ./mvnw quarkus:dev
and go to http://localhost:8080/h2
where the console should show up.