I went through the link: https://walkingtechie.blogspot.com/2018/12/execute-schema-and-data-sql-on-startup-spring-boot.html and Spring Boot - Loading Initial Data already, but still struggling to understand few things.
I'm looking to execute schema.sql
at the start of Spring Boot application run, for that I use below configuration. I want everything to be performed on Postgres DB.
I've created schema.sql file place in sql/schema.sql folder. I expect spring Boot to pick up that file and run it. Is there any way if we can do it ? I am using Spring Boot
version 2.1.6.RELEASE
and Postgres 11.0
.
spring:
datasource:
url: jdbc:postgresql://localhost:5432/test?currentSchema=test
username: postgres
password: postgres
platform: postgres
schema:
- classpath:sql/schema.sql
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
default_schema: test
format_sql: true
jdbc:
lob:
non_contextual_creation: true
show-sql: true
hibernate:
ddl-auto: none