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 ?
2 Answers
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.
1 Comment
maveric123
Thanks a lot Simon !!!! :) I made the changes as suggested and it did work!!! Yayyyyy
Yes, if you are using latest version of Spring Boot please enable spring.jpa.defer-datasource-initialization.
1 Comment
Community
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.