Executing script file in h2 database

后端 未结 4 1336
一向
一向 2020-12-04 13:03

First of all I would like to say am new to h2 database. I need to execute a sql script file in h2 database. I have a script file test.sql and I want to execute this in h2 da

4条回答
  •  甜味超标
    2020-12-04 13:35

    If you are using spring-boot and spring-test with H2 it will automatically look for schema.sql and data.sql in your class path and attempt to run these. So if you put them in src/test/resources they should be picked up and run automatically

    In addition you can specify the data files you want to run with properties. For example adding a property to yourapplication.properties like

    spring.datasource.data=classpath:users.sql, classpath:books.sql, classpath:reviews.sql
    

    will configure spring to run those three sql files instead of running data.sql

提交回复
热议问题