1

I am trying to create a simple SpringDataJPA application. I am using H2 database. After annotating the model class with @entity annotation the table is successfully created in H2 DB and the same can be viewed through the h2-console. however to initialise the table i am trying to insert the values from data.sql but while starting the application the error indicates that the table is not being found . Why is the table not being found when I am able to view the ?

POM.xml

Model Class

application.properties

data.sql

Console output

1

2 Answers 2

5

Spring Boot 2.5.0 changed the way schema.sql and data.sql are handled.

You have to set

spring.jpa.defer-datasource-initialization=true

to make your example work.

Please read https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto.data-initialization.using-basic-sql-scripts

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Simon !!!! :) I made the changes as suggested and it did work!!! Yayyyyy
0

Yes, if you are using latest version of Spring Boot please enable spring.jpa.defer-datasource-initialization.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.