仅在Linux中;org.postgresql.util.PSQLException:错误:关系;表“U名称”;不存在

仅在Linux中;org.postgresql.util.PSQLException:错误:关系;表“U名称”;不存在,postgresql,amazon-web-services,spring-boot,hibernate,Postgresql,Amazon Web Services,Spring Boot,Hibernate,我一直在寻找堆栈溢出和论坛,但到目前为止没有运气。我有一个SpringBoot2.3.3.RELEASE,JPA/Hibernate堆栈 我有一张桌子 CREATE TABLE_name(…) 我已经创建了不带引号和小写的表。它在本地很有效。在本地,我使用的是Amazon Corretto jdk11.0.8_10的Windows环境 现在我已经创建了一个AWS RDS PostreSQL DB实例。它托管在Linux上。 当我从Windows连接到DB时,它工作正常。但是当我在AWS Ela

我一直在寻找堆栈溢出和论坛,但到目前为止没有运气。我有一个SpringBoot2.3.3.RELEASE,JPA/Hibernate堆栈

我有一张桌子

CREATE TABLE_name(…)
我已经创建了不带引号和小写的表。它在本地很有效。在本地,我使用的是Amazon Corretto jdk11.0.8_10的Windows环境

现在我已经创建了一个AWS RDS PostreSQL DB实例。它托管在Linux上。 当我从Windows连接到DB时,它工作正常。但是当我在AWS Elastic Beanstalk上部署我的应用程序时,当Hibernate尝试查询数据库时,我出现了错误

org.postgresql.util.PSQLException: ERROR: relation "table_name" does not exist.
我的实体看起来像

@实体
@表(name=“Table_name”)
公共类用户{
}
该表位于默认的
public
架构中

我的
应用程序.properties

spring.datasource.url=jdbc:postgresql://${RDS_HOSTNAME}:${RDS_PORT}/${RDS_DB_NAME}
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=${RDS_USERNAME}
spring.datasource.password=${RDS_PASSWORD}
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL10Dialect
spring.jpa.properties.hibernate.globally_quoted_identifiers=false
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.default_schema=public
无论我是否将模式放入
@表中

我能发现的唯一区别是环境。Windows与Linux。当我在本地启动应用程序并使用AWS RDS DB时,它会工作。

对于诊断问题,您应该在

spring.datasource.url=jdbc:postgresql://${RDS_HOSTNAME}:${RDS_PORT}/${RDS_DB_NAME}
# ...
spring.datasource.username=${RDS_USERNAME}
spring.datasource.password=${RDS_PASSWORD}
你的Spring Boot版本是什么,PostgreSQL

这是样品

spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres_demo
spring.datasource.username=postgres
spring.datasource.password=123456

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update
注意:不要使用
org.hibernate.dialogue.postgresql10dialogue
,使用

spring.jpa.database=org.hibernate.dialect.PostgreSQLDialect

最后,我使用了错误的数据库名称。我使用了
postgres
作为数据库名。相反,它是
ebdb
。我不明白如何允许我通过DBeaver或PgAdmin连接到此
postgres
或如何在本地运行应用程序时连接到此DB名称,而不是在AWS中部署应用程序时

文件中提到了该名称:


您还可以在DB实例的AWS RDS配置选项卡中看到该名称。

您可以试试
spring.jpa.properties.hibernate.default\u schema=public
?您好,这是我文章中application.properties的最后一行;)不,这与na不同,顺便说一句,将您的
spring.jpa.hibernate.ddl auto=none
更改为
create
update
(如果有数据,请备份数据库)我确实按照您的建议将
spring.jpa.hibernate.ddl auto
设置为
update
。从创建表格的意义上讲,它是有效的。但问题是,我不知道在哪里!我通过应用程序向数据库中填充了一些数据,但当我以DBeaver作为用户名连接到数据库时,我看到了公共模式,但什么都没有。这就像有一个隐藏的模式,其中包含选项卡和Hibernate创建的数据。我迷路了!最后是DB名称的问题。我不明白它是如何在本地工作的,而不是在什么时候部署的。请回答。这是Spring Boot 2.3.3版本,Postgres 12.3hibernate映射说table
table\u name
不存在。这意味着连接信息是正确的。这个问题可能与不正确的模式有关,这是我首先想到的,但是当我将我的项目本地(Windows)连接到远程数据库时,它工作得很好。只有当我在AWS环境(Linux)中部署项目时才会发生这种情况。感谢您的帮助,它帮助我发现它不是正确的DB名称。