Subhayu
Subhayu

Reputation: 31

Migrating Spring Boot (3.0.5) with Spring Batch(5.0): Spring Batch specific "Auto Table creation" is not working

Old versions: Java: 11 Spring Boot : 2.5.2

After Migration : (new versions) Java:17 Spring Boot: 3.0.5 Spring Batch 5.0

Problem:

Spring batch related meta data (Auto table creation) is not working any more. (having “spring.jdbc.initialize-schema: always” defined in bootstrap.yml,and was working fine before upgrade) spring.datasource.url, spring.datasource.username, spring.datasource.password and spring.datasource.schema are all defined as it is (working before).

Just to try out: have defined below for Spring Boot to read the primary data source (which is spring Batch specific and not application specific) but no luck.

 @Configuration`
    public class DBConfig {
    @Primary
    @Bean(name = "dataSource")
    public DataSource dataSource() {
        DataSource dataSource = DataSourceBuilder.create().username("XXX")
                      .password("XXX$").url("jdbc:oracle:thin:@host:port/XXX").build();
        return dataSource;
    }
   }

Upvotes: 1

Views: 1491

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31600

I guess you are using @EnableBatchProcessing. If this is the case, that is the reason why tables are not created, see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#enablebatchprocessing-is-now-discouraged.

If you want to use @EnableBatchProcessing, then you need to initialize the database yourself, see example in Spring batch 5 and spring boot 3 meta data tables not created when using programmatic way of extending DefaultBatchConfiguration

Upvotes: 1

Related Questions