我有 postgresql 数据库,版本 11。在那里我创建了数据库模式“test”。 该架构的 SQL:
CREATE SCHEMA TEST
AUTHORIZATION "user-xxx";
ALTER DEFAULT PRIVILEGES IN SCHEMA test
GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES IN SCHEMA test
GRANT ALL ON TABLES TO PUBLIC;
我在 Spring Boot 中的配置:
datasource:
platform: postgres
jdbc-url: jdbc:postgresql://localhost:5432/BDA
username: user-xxx
password: user-xxx
jpa:
generate-ddl: true
properties:
hibernate:
default_schema: TEST
启动应用程序时,我总是遇到以下异常:
Can not connect from spring boot to postgresql schema - 'org.postgresql.util.PLSQLException: ERROR: schema "test" does not exist'
如果我不指定架构,那么它将使用默认数据库架构,并且一切正常。
最佳答案
我喜欢这个原因。当 jpa 驱动程序连接到 PostgreSQL 模式“TEST”时,它会小写字母,并搜索“test”。因此,我将架构重命名为“test”,将配置设置重命名为“test”,然后就能够连接了。
关于java - 无法从 Spring Boot 连接到 postgresql 架构 - 'org.postgresql.util.PLSQLException: ERROR: schema "测试“不存在”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61510707/