簡體   English   中英

Spring Boot - 如何為 PostgreSQL 設置默認架構?

[英]Spring Boot - How to set the default schema for PostgreSQL?

我目前在application.properties文件中所做的是:

spring.datasource.url=jdbc:postgresql://localhost:5432/myDB?currentSchema=mySchema

沒有其他屬性可以用於此嗎? 由於它看起來很 hacky 並且根據帖子(仍然找到鏈接抱歉,稍后會更新),它僅適用於 PostgreSQL 9.4。

您可以嘗試為jdbc用戶設置默認架構。

1)ALTER USER用戶名SET搜索路徑到'schema'

2)您嘗試過此酒店嗎? spring.datasource.schema

http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html

由於這已經很老了,還沒有適當的答案,因此要設置的正確屬性如下:

spring.jpa.properties.hibernate.default_schema=yourschema

SpringBoot 2.5.5 是唯一對我有用的東西:

應用程序屬性

spring.datasource.hikari.schema=my_schema

aplication.yml 版本:

spring:
  datasource:
    hikari:
      schema: my_schema

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM