You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spring Boot can automatically create the schema (DDL scripts) of your JDBC `DataSource` or R2DBC `ConnectionFactory` and initialize it (DML scripts).
42
-
It loads SQL from the standard root classpath locations: `schema.sql` and `data.sql`, respectively.
43
-
In addition, Spring Boot processes the `schema-$\{platform}.sql` and `data-$\{platform}.sql` files (if present), where `platform` is the value of configprop:spring.sql.init.platform[].
41
+
Spring Boot can automatically create the schema (DDL scripts) of your JDBC `DataSource` or R2DBC `ConnectionFactory` and initialize its data (DML scripts).
42
+
43
+
By default, it loads schema scripts from `optional:classpath*:schema.sql` and data scripts from `optional:classpath*:data.sql`.
44
+
The locations of these schema and data scripts can customized using configprop:spring.sql.init.schema-locations[] and configprop:spring.sql.init.data-locations[] respectively.
45
+
The `optional:` prefix means that the application will start when the files do not exist.
46
+
To have the application fail to start when the files are absent, remove the `optional:` prefix.
47
+
48
+
In addition, Spring Boot processes the `optional:classpath*:schema-$\{platform}.sql` and `optional:classpath*:data-$\{platform}.sql` files (if present), where `$\{platform}` is the value of configprop:spring.sql.init.platform[].
44
49
This allows you to switch to database-specific scripts if necessary.
45
50
For example, you might choose to set it to the vendor name of the database (`hsqldb`, `h2`, `oracle`, `mysql`, `postgresql`, and so on).
51
+
46
52
By default, SQL database initialization is only performed when using an embedded in-memory database.
47
53
To always initialize an SQL database, irrespective of its type, set configprop:spring.sql.init.mode[] to `always`.
48
54
Similarly, to disable initialization, set configprop:spring.sql.init.mode[] to `never`.
0 commit comments