Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
Springboot default data.sql not loading on startup

I've got this springboot application that is working with a postgresql database. My application-dev.properties file is as follows:

spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=root


spring.datasource.data=classpath:/sql/dev-data.sql


spring.jpa.properties.hibernate.default_schema=myschema

spring.jpa.show-sql=true
spring.jpa.database=POSTGRESQL

The database is installed in my development machine, and already initialized. dev-data.sql is in src/main/resources/sql and right now only deletes everything on a specific table (lets call it myschema.example_table) and inserts some registries. (This is intended to check the functionality works than for an actual use):

delete from myschema.example_table where id > 0;

insert into myschema.example_table (id, val1, val2) values (1, "Hello", "Petecander");
insert into myschema.example_table (id, val1, val2) values (2, "Goodbye", "Gromenauer");

My issue is that... nothing happens. Is as if there wasn't anything related to the dev-data.sql file at all. So, I'm completely at a loss here. I've been browsing for a while, and reading about a lot of different switches that can be enabled on the application.properties file, but nothing. Any idea?

EDIT: Just to provide a bit more of info that I've been asked down there: The application loads fine and can perform some basic CRUD stuff against the database (Just read stuff at the moment), so the application-dev.properties file seens that is being loaded right.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Hibernate will only execute data.sql for create or create-drop

Add the following property to your application properties spring.jpa.hibernate.ddl-auto=create or spring.jpa.hibernate.ddl-auto=create-drop

This is required along with the property spring.datasource.initialization-mode=always for external (not embedded) databases.

over 4 years ago · Santiago Trujillo Report

0

Did you try to name file data.sql? I think it could help https://www.baeldung.com/spring-boot-data-sql-and-schema-sql

over 4 years ago · Santiago Trujillo Report

0

I've faced a similar issue and found my answer here. If you add:

spring.datasource.initialization-mode=always

To your properties it should work.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!