添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
闯红灯的台灯  ·  unity读取服务器数据库·  2 年前    · 
玩滑板的冲锋衣  ·  PHP date("Y-m-d ...·  2 年前    · 
冷冷的沙发  ·  java - Header in the ...·  3 年前    · 
有腹肌的扁豆  ·  在Asp.Net ...·  3 年前    · 

springboot h2 持久化

Spring Boot配合H2数据库实现持久化需要在配置文件中进行一些额外的设置。首先,您需要在pom.xml文件中添加对h2数据库的依赖:

<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <scope>runtime</scope>
</dependency>

然后,您可以在 application.properties 或者 application.yml 文件中设置 H2 数据库的相关信息,例如:

spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.hibernate.ddl-auto=update

这样,在您的 Spring Boot 应用程序启动时,H2 数据库就会被创建,并且您在数据库中执行的所有操作都会被持久化到硬盘上。

  •