首页 > 解决方案 > 带有spring boot的Postgresql - 每当我启动应用程序时数据库都是空的

问题描述

我正在学习 Spring Boot,我创建了一个简单的应用程序,我在其中连接到 postgresql 数据库并执行简单的插入/更新/删除操作。一切正常,但如果我停止应用程序,我在数据库中添加的行不会保留在数据库中。我必须在某处指定一种提交吗?
这是application.properties文件:

spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/testdb
spring.datasource.username=postgres
spring.datasource.password=*pass*
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create

标签: postgresqlspring-boot

解决方案


改成:

spring.jpa.hibernate.ddl-auto=更新

阅读:Spring Boot ddl 自动生成器


推荐阅读