0

I am trying to integrate spring boot with postgres db. Everything works fine except that the tables are being created in the public schema even though I am specifying a particular schema in the application.properties

spring.datasource.schema=AngSpring

application.properties

spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/NGP_DB
spring.datasource.schema=AngSpring
spring.datasource.username=jdbcusr
spring.datasource.password=password

You can see in the postgres db screenshot that the task_list table is created under 'public' schema. According to the property file it should come under the 'AngSpring' schema.

Schema description

Please correct me if Iam doing anything wrong in the code.

Xtreme Biker
  • 28,480
  • 12
  • 120
  • 195
Sarun UK
  • 3,862
  • 5
  • 13
  • 34

1 Answers1

3

I guess the spring.datasource.schema property is used to specify the location of a concrete schema script file in your application to generate the database, so you should remove it.

Instead, it seems that you want to use the one that Hibernate guesses from your entitities and put it in an specific schema location in your postgres database. Use the schema in the url instead:

 spring.datasource.url=jdbc:postgresql://localhost:5432/NGP_DB?currentSchema=AngSpring

See also:

Community
  • 1
  • 1
Xtreme Biker
  • 28,480
  • 12
  • 120
  • 195