Harmonize database initializers

This commit updates database initializers configuration to enable them
automatically only when an embedded `DataSource` is used. Related
configuration properties have been updated to use a more expressive
`DatabaseInitializerMode` enum rather than `Boolean` flag.

See gh-9752
This commit is contained in:
Vedran Pavic
2017-07-13 13:27:46 +02:00
committed by Stephane Nicoll
parent 29078c78f2
commit 14b7be8325
19 changed files with 145 additions and 159 deletions

View File

@@ -132,7 +132,7 @@ content into your application; rather pick only the properties that you need.
# QUARTZ SCHEDULER ({sc-spring-boot-autoconfigure}/quartz/QuartzProperties.{sc-ext}[QuartzProperties])
spring.quartz.job-store-type=memory # Quartz job store type.
spring.quartz.properties.*= # Additional Quartz Scheduler properties.
spring.quartz.jdbc.initialize-schema=false # Create the required Quartz Scheduler tables on startup.
spring.quartz.jdbc.initialize-schema=embedded # Quartz Scheduler database schema initialization mode.
spring.quartz.jdbc.schema=classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
# Reactor
@@ -416,7 +416,7 @@ content into your application; rather pick only the properties that you need.
# SPRING SESSION ({sc-spring-boot-autoconfigure}/session/SessionProperties.{sc-ext}[SessionProperties])
spring.session.hazelcast.flush-mode=on-save # Sessions flush mode.
spring.session.hazelcast.map-name=spring:session:sessions # Name of the map used to store sessions.
spring.session.jdbc.initializer.enabled= # Create the required session tables on startup if necessary. Enabled automatically if the default table name is set or a custom schema is configured.
spring.session.jdbc.initialize-schema=embedded # Spring Session database schema initialization mode.
spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions.
spring.session.redis.flush-mode=on-save # Sessions flush mode.
@@ -942,14 +942,14 @@ content into your application; rather pick only the properties that you need.
spring.artemis.user= # Login user of the broker.
# SPRING BATCH ({sc-spring-boot-autoconfigure}/batch/BatchProperties.{sc-ext}[BatchProperties])
spring.batch.initializer.enabled= # Create the required batch tables on startup if necessary. Enabled automatically if no custom table prefix is set or if a custom schema is configured.
spring.batch.initialize-schema=embedded # Spring Batch database schema initialization mode.
spring.batch.job.enabled=true # Execute all Spring Batch jobs in the context on startup.
spring.batch.job.names= # Comma-separated list of job names to execute on startup (For instance `job1,job2`). By default, all Jobs found in the context are executed.
spring.batch.schema=classpath:org/springframework/batch/core/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.batch.table-prefix= # Table prefix for all the batch meta-data tables.
# SPRING INTEGRATION ({sc-spring-boot-autoconfigure}/integration/IntegrationProperties.{sc-ext}[IntegrationProperties])
spring.integration.jdbc.initializer.enabled=false # Create the required integration tables on startup.
spring.integration.jdbc.initialize-schema=embedded # Spring Integration database schema initialization mode.
spring.integration.jdbc.schema=classpath:org/springframework/integration/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
# JMS ({sc-spring-boot-autoconfigure}/jms/JmsProperties.{sc-ext}[JmsProperties])

View File

@@ -1936,11 +1936,12 @@ data.
=== Initialize a Spring Batch database
If you are using Spring Batch then it comes pre-packaged with SQL initialization scripts
for most popular database platforms. Spring Boot will detect your database type, and
execute those scripts by default, and in this case will switch the fail fast setting to
false (errors are logged but do not prevent the application from starting). This is
because the scripts are known to be reliable and generally do not contain bugs, so errors
are ignorable, and ignoring them makes the scripts idempotent. You can switch off the
initialization explicitly using `spring.batch.initializer.enabled=false`.
execute those scripts by default when using an embedded database, and in this case will
switch the fail fast setting to false (errors are logged but do not prevent the
application from starting). This is because the scripts are known to be reliable and
generally do not contain bugs, so errors are ignorable, and ignoring them makes the
scripts idempotent. You can switch off the initialization explicitly using
`spring.batch.initialize-schema=never`.

View File

@@ -5568,7 +5568,7 @@ on startup:
[source,properties,indent=0]
----
spring.integration.jdbc.initializer.enabled=true
spring.integration.jdbc.initialize-schema=always
----
See the