Problems with automatic execution of jpa,data.sql files in spring boot. How did it come true?

spring bootmaven1.3
spring-boot-starter-data-jpa
oracle 11g
:
spring.jpa.hibernate.ddl-auto=update
src/main/resourcesdata.sqlinsert intosql

start the project, and the SYS_ row table will be created in the database and generated by jpa according to
@ Entity
public class SysRole {
. At the same time, the statements in data.sql are executed to insert data into the table.

question: where is jpa configured? will you find the data.sql file and execute the sql statement inside?

however, in boot version 2.0, it was found that the sql statement in the data.sql file was not executed.

Mar.21,2021

SpringBoot loads the schema.sql and data.sql scripts under the classpath by default.
see DataSourceAutoConfiguration and DataSourceInitializer for specific source code.

Menu