エラー内容。
以下のテストコードを実行すると、テーブルを見つけられないエラーが発生してしまった。。。
エンティティクラスにEntityアノテーションを定義してあったのに、テーブルを参照できないとエラーが発生した。
それで色々調べてみたら、springboot2.5 versionがリリースによりある設定が必要になった。
Hibernate and data.sql
By default, data.sql scripts are now run before Hibernate is initialized. This aligns the behavior of basic script-based initialization with that of Flyway and Liquibase. If you want to use data.sql to populate a schema created by Hibernate, set spring.jpa.defer-datasource-initialization to true. While mixing database initialization technologies is not recommended, this will also allow you to use a schema.sql script to build upon a Hibernate-created schema before it’s populated via data.sql.
If you want to use data.sql to populate a schema created by Hibernate, set spring.jpa.defer-datasource-initialization to true
data.sqlを使って、Hibernateにより作成されたスキーマをpopulateするためには「spring.jpa.defer-datasource-initialization」をtrueに設定する必要があるとのこと!
以下のように、application.propertiesに設定しておけば、assertionエラーは出ているが先のテーブル参照エラーは解消したのがわかる!