diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AbstractBatchConfiguration.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AbstractBatchConfiguration.java index 32d09dac2..bd51bef4f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AbstractBatchConfiguration.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/AbstractBatchConfiguration.java @@ -20,7 +20,6 @@ import org.springframework.batch.core.configuration.support.MapJobRegistry; import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.scope.StepScope; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -31,6 +30,8 @@ import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.type.AnnotationMetadata; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.util.Assert; +import org.springframework.batch.core.scope.JobScope; +import org.springframework.batch.core.scope.StepScope; import javax.sql.DataSource; import java.util.Collection; @@ -44,7 +45,7 @@ import java.util.Collection; * @see EnableBatchProcessing */ @Configuration -@Import(StepScopeConfiguration.class) +@Import(ScopeConfiguration.class) public abstract class AbstractBatchConfiguration implements ImportAware { @Autowired @@ -129,14 +130,21 @@ public abstract class AbstractBatchConfiguration implements ImportAware { * */ @Configuration -class StepScopeConfiguration { +class ScopeConfiguration { private StepScope stepScope = new StepScope(); + private JobScope jobScope = new JobScope(); + @Bean public StepScope stepScope() { stepScope.setAutoProxy(false); return stepScope; } + @Bean + public JobScope jobScope() { + jobScope.setAutoProxy(false); + return jobScope; + } } \ No newline at end of file diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java index cedf8cc83..5dea5f600 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java @@ -89,7 +89,8 @@ import java.lang.annotation.Target; * * Note that only one of your configuration classes needs to have the @EnableBatchProcessing * annotation. Once you have an @EnableBatchProcessing class in your configuration you will have an - * instance of {@link StepScope} so your beans inside steps can have @Scope("step"). You will also be + * instance of {@link StepScope} and {@link org.springframework.batch.core.scope.JobScope} so your beans inside steps + * can have @Scope("step") and @Scope("job") respectively. You will also be * able to @Autowired some useful stuff into your context: * *