From 0bb4de490d80cb305bdfdd55e6ae88a37e096ada Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 11 Dec 2015 11:03:52 +0000 Subject: [PATCH] Allow any ExitCodeGenerator bean to switch of auto-configured bean In bedf2edf, the return type of the auto-configuration method that creates batch's ExitCodeGenerator was changed from ExitCodeGenerator to JobExecutionExitCodeGenerator but the on missing bean condition was left unchanged. This means that the auto-configured bean can only be switched off by a JobExecutionExitCodeGenerator bean, rather than any bean that implements ExitCodeGenerator. This commit corrects the use of @ConditionalOnMissingBean to allow any ExitCodeGenerator bean to switch off the auto-configured one. Closes gh-4752 --- .../boot/autoconfigure/batch/BatchAutoConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index a026ba226a1..4270dd5db19 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -29,6 +29,7 @@ import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.launch.support.SimpleJobOperator; import org.springframework.batch.core.repository.JobRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ExitCodeGenerator; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -91,7 +92,7 @@ public class BatchAutoConfiguration { } @Bean - @ConditionalOnMissingBean + @ConditionalOnMissingBean(ExitCodeGenerator.class) public JobExecutionExitCodeGenerator jobExecutionExitCodeGenerator() { return new JobExecutionExitCodeGenerator(); }