A common way to auto-create a database schema in a Spring Boot JPA application is just to set a
spring.jpa.hibernate.ddl-auto property to
update. This would create a schema matching the entity classes in your application, when your application starts.
But, sometimes you may like to create a schema for which you have not defined entity classes. For example, if you are coding an authorization server by using spring-security-oauth2, you may like to create a schema like this.
Spring Boot provides an easy way to do so! If you place files named
data.sql in classpath root (i.e.
src/main/resurces), they’ll be run when your application starts.
It’s a powerful feature – for example, you can have different initialization scripts for different database providers. Visit Spring Boot reference for more details.