如何从application.properties文件设置h2.jdbc? [英] How to set h2.jdbc from application.properties file?

查看:407
本文介绍了如何从application.properties文件设置h2.jdbc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是H2和H2-Console的粉丝.不幸的是,当我在java spring-boot应用程序上运行h2时,默认情况下JDBC URLjdbc:h2:~/test 同时应该是jdbc:h2:mem:testdb才能看到保存的对象.

I am a fan of H2, and H2-Console. Unfortunatly, when i run the h2 on my java spring-boot application, by default the JDBC URL is as jdbc:h2:~/test meanwhile it should be jdbc:h2:mem:testdb to be able to see the saved objects.

所以,我想知道是否可以通过 application.properties配置此JDBC URL?

So, I am wondering if there is a way to configure this JDBC URL from the application.properties or not?

下图更好地显示了我在说什么:

The below image shows better what i am talking about:

推荐答案

您可以使用以下属性通过application.properties文件连接h2数据库

You can use below properties for connecting h2 database via application.properties file

spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.datasource.url=jdbc:h2:mem:testdb 
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver

这篇关于如何从application.properties文件设置h2.jdbc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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