簡體   English   中英

springboot2.6:defer-initialization-mode 設置為 true:data.sql 未初始化

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

我正在將我的 springboot 從 2.2 升級到 2.6。 作為此升級的一部分,當我使用 inMemory H2 數據庫測試 JUNIT 時,盡管有 data.sql,但所有測試都開始失敗並丟失數據。 我查看了 spring 文檔並在我的 application.yml 文件中進行了以下更改。

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


    

盡管使用了上述選項,但我沒有看到我的數據。sql 數據在測試用例中可見,我所有的測試用例都開始失敗。有人遇到過類似的問題嗎? 如果是這樣,可能的解決方案是什么?

你只需要改變你的 data.sql 到 import.sql

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM