【发布时间】:2020-03-23 19:41:42
【问题描述】:
我正在用 Java 中的 Rest api 完成一个培训项目,
使用springboot 和postgresql 数据库。
我试图在启动时使用schema.sql 和data.sql 初始化数据库。
当我使用该配置文件通过PgAdmin 直接查看数据库时,创建和data injections 工作正常。
spring.datasource.url = jdbc:postgresql://localhost:5432/db_test
spring.datasource.username = adm_library
spring.datasource.password = admin
spring.datasource.driver-class-name = org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect
#hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.datasource.initialization-mode=always
#spring.jpa.hibernate.ddl-auto = none
但是,如果我尝试立即使用该应用程序,我会得到 p>
org.postgresql.util.PSQLException: ERREUR: 关系 « book » 不存在
这里导致错误的实体是“书”,因为我尝试检索书籍,但如果我尝试检索用户等,它可能是“用户”... 我找到了一种通过重新启动应用程序来使其工作的方法
spring.datasource.initialization-mode=always
然后就没事了。 关于这种行为的任何解释? 谢谢!
【问题讨论】:
标签: java spring postgresql hibernate spring-boot