Spring Batch uses default datasource and it stores metadata in database tables. This posts shows you how to change database schema and prefix for Spring Batch metadata tables..
Spring Batch requires datasource and it stores metadata in tables started with BATCH_ prefix located in default datasource schema (
spring.jpa.properties.hibernate.default_schema doesn’t work).
Let’s consider the following scenarios:
- How to change table prefix from BATCH_ to the different one
- How to change database schema
- How to set database schema to the same as JPA default schema
Solution A: How to change table prefix from BATCH_ to the different one
spring.batch.tablePrefix property in
application.properties file, to change default table prefix. In the following example table prefix was changed from
Solution B: How to change database schema
Changing database schema for Spring Batch metadata tables is configured by setting the same property as it was shown in the previous solution. In the following example metadata schema was changed to
MY_SCHEMA and table prefix was changed from
Solution C: How to set database schema to JPA default schema
You can implement the mentioned requirement by setting
spring.batch.tablePrefix property like in the following example.