如何从application.properties文件设置h2.jdbc? [英] How to set h2.jdbc from application.properties file?
问题描述
我是H2和H2-Console的粉丝.不幸的是,当我在java spring-boot应用程序上运行h2时,默认情况下JDBC URL
为jdbc: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屋!