I am trying to initialize a database and insert some data using spring boot. According to the documentation, I just need a data.sql file inside the resourses folder to execute my sql initial data, but for some reason my data.sql is being ignored.
Here is my application.properties file:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/urmamma
spring.datasource.username=root
spring.datasource.password=
spring.session.jdbc.initialize-schema=always
#spring.data.jpa.repositories.bootstrap-mode=default
#spring.datasource.data=classpath:data.sql
My data.sql file:
insert into user (id, email, name) values (1, '[email protected]', 'Teobaldo')
dependencies using gradle:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.data:spring-data-rest-hal-explorer'
implementation 'org.springframework.session:spring-session-jdbc'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
question from:
https://stackoverflow.com/questions/65924918/data-sql-wont-execute 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…