spring boot – loading the initial data to the database

The problem is that spring expects to find a file with either the name schema.sql or data.sql in the classpath to load.

But your file is named data-h2.sql so spring will not consider it, even if it is correctly placed in resources.

It could search for a file with the name data-h2.sql and load it if you had configured the property spring.datasource.platform = h2.

Without using the aforementioned property, there are 2 solutions:

  1. Rename the file into data.sql and be sure it is inside the resources folder

  2. Do not rename the file and use the following application property to inform spring about the name of the file that it should load spring.sql.init.data-locations=classpath:data-h2.sql

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top