更新时间:2023-02-03 15:44:50
SQL 脚本数据源初始化功能已在 Spring Boot 2.5 中重新设计.
The SQL Script DataSource Initialization feature has been redesigned in Spring Boot 2.5.
默认情况下,data.sql
脚本现在在 Hibernate 之前运行初始化.这与基于脚本的基本行为保持一致Flyway 和 Liquibase 的初始化.如果你想使用data.sql
填充由 Hibernate 创建的模式,设置spring.jpa.defer-datasource-initialization
到 true
.搅拌时不推荐使用数据库初始化技术,这会还允许您使用 schema.sql
脚本来构建在通过 data.sql
填充之前由 Hibernate 创建的模式.
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 usedata.sql
to populate a schema created by Hibernate, setspring.jpa.defer-datasource-initialization
totrue
. While mixing database initialization technologies is not recommended, this will also allow you to use aschema.sql
script to build upon a Hibernate-created schema before it’s populated viadata.sql
.
参考