0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SpringBoot2.5.1以降でDBの初期化が走らない

Posted at

こちらの記事のSpringBoot2.5.1以降の解消手順です。

結論

以下を設定してください。

application.properties
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:./target/db/testdb
spring.datasource.username=sa
spring.datasource.password=
spring.sql.init.mode=always
spring.sql.init.schema-locations=classpath:schema.sql
spring.sql.init.data-locations=classpath:data.sql

SpringBoot2.5.0以前は

application.properties
spring.datasource.initialization-mode=always
spring.datasource.schema=classpath:schema.sql

SpringBoot2.5.0では

application.properties
spring.sql.init.enabled=true
spring.sql.init.schema-locations=classpath:schema.sql
spring.sql.init.data-locations=classpath:data.sql

細かい補足

  • spring.sql.init.mode 2.5.1から変わったっぽいです。
    • あんまり情報が出てこなくてめっちゃ困りましたが、こちらのコミットで変更されていそう。
  • 2.5.0からspring.datasourceでまとめられていたプロパティ群がspring.sql.initに切り出されたみたいです。
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?