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

查看:493
本文介绍了如何在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

推荐答案

您可以使用浏览器中的Web界面启用h2 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天全站免登陆