首页 > 数据库技术 > 详细

[Spring boot] Configuring and Accessing a Data Source

时间:2019-01-14 22:42:53      阅读:177      评论:0      收藏:0      [点我收藏+]

We need our data persistence with configuring our datasouce:

In application.properties:

spring.h2.console.enabled=true
spring.h2.console.path=/h2

spring.datasource.url=jdbc:h2:file:~/gs-spring-boot
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver

spring.datasource.max-active=10
spring.datasource.max-idl=8
spring.datasource.max-wait=10000
spring.datasource.min-evictable-idle-time-millis=1000
spring.datasource.min-idle=8
spring.datasource.time-between-eviction-runs-millis=1

 

"

spring.datasource.url=jdbc:h2:file:~/gs-spring-boot

" tells to save the in memory data into a file called ‘gs-spring-boot‘, you can name the file whatever you want.

 

Rebuild the application, login h2:

技术分享图片

Make sure you change the JDBC URL. Now everytime you restart the server, data won‘t lost

 

[Spring boot] Configuring and Accessing a Data Source

原文:https://www.cnblogs.com/Answer1215/p/10269283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!