java - 无法从 Spring Boot 连接到 postgresql 架构 - 'org.postgresql.util.PLSQLException: ERROR: schema "测试“不存在”

标签 java postgresql hibernate spring-boot jpa

我有 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/

相关文章:

sql - 按联接表中的列排序的慢查询

java - Spring Boot - Maven 构建错误

java - 如何在java中查找操作系统上次更新的时间

java - 如何在 JPA 中设置来自 @EmbeddedId 的反向引用

java - java web 系统 192MB JVM 堆大小可以吗?

postgresql - 更改 Postgres.app 使用的 Postgresql 版本

r - 如何使用 R 连接到远程 PostgreSQL,需要证书验证

java - 无法创建请求的服务 [org.hibernate.cache.spi.RegionFactory] ​​- Hibernate 4.3.8

java - Criteria API JPA 2 - JOIN 导致 MySQLSyntaxErrorException : You have an error in your SQL syntax

java - 用方法调用替换来自字段的 java 方法调用