[Spring boot] Configuring and Accessing a Data Source

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Spring boot] Configuring and Accessing a Data Source相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章