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

时间:2015-06-15 15:17:25

标签: java spring hibernate postgresql

What I am currently doing in my application.properties file is:

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

Isn't there another property for this? Since it looks hacky and according to a post (still finding the link sorry, will update later), it is only applicable to PostgreSQL 9.4.

2 个答案:

答案 0 :(得分:2)

您可以尝试为jdbc用户设置默认架构。

1) ALTER USER user_name将search_path设置为' schema'

2)你试过这个属性吗? spring.datasource.schema

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

答案 1 :(得分:1)

由于这已经很老了,还没有适当的答案,因此要设置的正确属性如下:

spring.jpa.properties.hibernate.default_schema=yourschema