【问题标题】:Spring boot application not able to find sequence in AWS PostgresqlSpring Boot 应用程序无法在 AWS Postgresql 中找到序列
【发布时间】:2022-12-15 05:21:35
【问题描述】:
在现有的 spring boot 应用程序中,我创建了新实体,并为此实体的主键使用了注释 @GeneratedValue。
基于实体和注释,我在 Postgresql 数据库中创建了所需的表和序列。(注意,Spring boot 和数据库已存在)
但是,在启动 spring boot 应用程序时出现错误“无法构建 Hibernate SessionFactory 模式验证:缺少序列”,并且序列是在所需模式下的数据库中创建的。
Spring boot 应用程序识别在 Postgresql 中创建的序列并启动应用程序。
【问题讨论】:
标签:
java
postgresql
amazon-web-services
spring-boot
hibernate
【解决方案1】:
在 Postgresql 数据库表中,我们需要向用户提供权限(如插入、删除更新),spring boot 应用程序将通过该权限与数据库连接。这样 spring boot 应用程序就可以在表/序列中执行读/写等操作。
例如:在 spring boot 应用程序中,application.properties 文件中提到的数据库用户是 dbuser/password。然后确保在 Postgresql DB 端此用户 dbuser 应该是表的所有者并且具有插入,更新,删除等访问权限。