Importing Data with spring boot

后端 未结 5 1128
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 07:21

I have flyway and spring-boot working correctly, but I can\'t seem to wire up my spring.datasource.data correctly.

If I have a file src/main/resou

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 07:29

    Stuck at that quite long. My context: Spring Boot 2.2.6 + Hibernate 5.4 + script.sql in classpath(src/main/resources). To make script executed at application start I was need to add in application.properties:

    spring.datasource.initialization-mode=always
    spring.jpa.hibernate.ddl-auto=update
    spring.datasource.data=classpath:script.sql
    

    And remove all comments BEFORE the actual code and BETWEEN code in script.sql. Or if you need comments, add SELECT 1; on the next line after the line with comment. Because the next line after commented one seems to be ignored. No matter how many line breaks after line with comment you paste.

提交回复
热议问题