如何在 Spring Boot 中启用 H2 数据库服务器模式 [英] How to enable H2 Database Server Mode in Spring Boot

查看:46
本文介绍了如何在 Spring Boot 中启用 H2 数据库服务器模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有使用 Spring Boot 的文件的 H2 数据库.

I'm using a H2 database with a file using Spring Boot.

在我的 application.properties 中,我有这个条目:

In my application.properties, I have this entry:

spring.datasource.url=jdbc:h2:file:c:/Testprojekte/spring-boot-h2-db

spring.datasource.url=jdbc:h2:file:c:/Testprojekte/spring-boot-h2-db

但现在我希望能够在运行应用程序时查看数据库,目前这是不可能的,因为我需要在服务器模式下运行数据库才能这样做.在文档中,我发现我必须将 AUTO_SERVER=TRUE 添加到 URL 中,但这并不能解决问题.

But now I would like to be able to look at the database while running the application, which currently isn't possible because I need to have the database running in server mode in order to do so. In the documentation I found that I have to add AUTO_SERVER=TRUE to the URL but this doesn't solve the problem.

那么,我需要更改什么才能同时从不同的进程连接到该数据库?

So, what do I have to change to be able to connect to that database from different processes at the same time ?

感谢您的帮助!托尔斯滕

thanks for any help! Thorsten

推荐答案

您可以启用 h2 Web 控制台,以使用浏览器中的 Web 界面访问内存或文件数据库中的 h2.

You can enable h2 web console to access your h2 in memory or in file database using a web interface in your browser.

为此在 application.properties 中添加以下行:

therefor add in application.properties the lines:

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console

然后重启你的spring boot应用程序并用你的浏览器检查http://localhost:8080/h2-console.

after that restart your spring boot application and check http://localhost:8080/h2-console with your browser.

这篇关于如何在 Spring Boot 中启用 H2 数据库服务器模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆