且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Boot 不会自动创建表

更新时间: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-initializationtrue.搅拌时不推荐使用数据库初始化技术,这会还允许您使用 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 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.

参考

Spring Boot 2.5 发行说明