如何从application.properties文件中设置h2.jdbc?

时间:2017-09-30 13:34:30

标签: spring spring-boot jdbc h2

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

所以,我想知道是否有办法从 application.properties配置此JDBC URL?

下图更好地展示了我所说的内容:

enter image description here

1 个答案:

答案 0 :(得分:2)

您可以使用以下属性通过h2文件

连接application.properties数据库
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
相关问题