'springboot2.6: defer-initialization-mode set to true: data.sql is not initialized

I am upgrading my springboot from 2.2 to 2.6. As part of this upgrade, when I am testing JUNITs using inMemory H2 database, all tests started failing with missing data despite having data.sql. I reviewed spring docs and made following changes in my application.yml file.

spring.sql.init.mode: always
spring.jpa.defer-datasource-initialization: true
spring.jpa.generated-ddl: true # tried this option without hibernate one too
spring.jpoa.hibernate.ddl-auto: create-drop #tried this option alone too along with changing to create


    

Despite using above options, I dont see my data.sql data visible in test cases and all my test cases started to fail.Did anyone encounter similar issue? If so, what would be possible resolution?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source