How to set h2.jdbc from application.properties file?

拜拜、爱过 提交于 2019-12-23 03:13:20

问题


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.

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:


回答1:


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


来源:https://stackoverflow.com/questions/46503219/how-to-set-h2-jdbc-from-application-properties-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!