Spring Boot
September 9, 2021
M04 Q12 - How do you configure default schema and initial data?
Spring Boot uses following scripts to configure default schema and initial data:
schema.sql– contains DDL for db objects creationdata.sql– contains data that should be inserted upon db initialization
platform is the value of spring.datasource.platform property, this allows you to switch between database vendor specific scripts, for example platform may be mysql, postgressql, oracle etc.
spring.datasource.platform=mysql
Spring Boot will automatically initialize only embedded databases, if you want to initialize regular database as well, you need to set property spring.datasource.initialization-mode to always.
spring.datasource.initialization-mode=always
If you would like to change default schema.sql and data.sql script names, you can use spring.datasource.schema and spring.datasource.data properties to achieve this.