码迷,mamicode.com
首页 > 数据库 > 详细

[Spring boot] Configuring and Accessing a Data Source

时间:2019-01-14 23:04:58      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:change   hang   cal   inf   ble   mem   path   access   int   

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

标签:change   hang   cal   inf   ble   mem   path   access   int   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!