Skip to content
Advertisement

I get empty list from findAll Spring data and h2 data base while the database is not empty

I have a spring boot API project with h2 database. I added some data in the data.sql but the data wasn’t inserted into the database however tables are created successfully when I call the findAll API I get an empty list due to the database tables are empty.

Application.properties

JavaScript

data.sql

JavaScript

Pom.xml

JavaScript

Main Class

JavaScript

Gateway.java

JavaScript

Repository

JavaScript

Controller

JavaScript

project structure

enter image description here

Advertisement

Answer

Add the following to your application properties to stop JPA auto generating your gateway table over the top of your data.sql.

JavaScript

By the way, this is the only thing you need in your application.properties, as all the rest is default.

Advertisement