spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.34k stars 40.72k forks source link

Add auto-configuration for Spring Batch's MongoJobRepository #43236

Open philwebb opened 4 days ago

philwebb commented 4 days ago

Sample at https://github.com/joshlong-attic/2024-11-20-batch-job-repository

philwebb commented 4 days ago

This bug exists in earlier versions, but given it's mostly going to be triggered by the new MongoJobRepositoryFactoryBean I think we should keep the target to 3.4

philwebb commented 4 days ago

The sample now appears to start if:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

and

    @Bean
    MongoTransactionManager mongoTransactionManager(MongoDatabaseFactory dbf) {
        return new MongoTransactionManager(dbf);
    }
philwebb commented 3 days ago

@mbhave pointed out that BatchAutoConfiguration depends on DataSource so it may back off entirely with the pring-boot-starter-jdbc exclusion. We probably need a more complete fix for Mongo support.

That might need to wait until 3.5, in which case we could revert my "fix" in 3.4

wilkinsona commented 2 days ago

Chatting with @fmbenhassine, this may need to wait for Spring Boot 4.0/Spring Batch 6.0 to allow some breaking changes to be made, such as DefaultBatchConfiguration losing its DataSource assumptions.