简体   繁体   中英

Not able to connect to specific schema of aws postgres using spring boot application

I have created an specific schema(example myschema) in aws postgre service and I am trying to connect with my spring boot application. But It is not working. I am successfully able to connect to public schema for aws postgre, but not able to connect with new schema created. I have tried using below two method:

  1. Appending schema in jdbc url: jdbc:postgresql://xxxxxxxxxx/mydatabase?currentSchema=myschema But in here my application is performing CRUD in public schema.
  2. I tried to add below two properties in application.properties,

spring.datasource.hikari.schema=myschema AND spring.jpa.properties.hibernate.default_schema=myschema

since I am using spring.jpa.hibernate.ddl-auto=validate, property, while starting spring application it is getting failed and showing error like "org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table" but the table and required objects created.

Kindly suggest me related to this issue.

You have two options:

  1. using of default_schema in application properties

    spring.jpa.properties.hibernate.default_schema: my_custom_schema

  2. explicitly specifying schema for each entity

    @Entity
    @Table(name = "my_table", schema = "my_custom_schema")

You don't need to patch jdbc url in any way. I use hikari but I've never specified spring.datasource.hikari.schema. It looks redundant

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM