I have tried to find the answer for seemingly simple but the evasive question. How does spring identify jobs in the batch configuration. Everything is annotated with @Bean and nothing to identify. Does the spring identify those with keywords in the name itself? Like xyzStep xzyJob etc? I'm trying to follow the official documentation at here
Thanks in advance.
Everything is annotated with @Bean and nothing to identify. Does the spring identify those with keywords in the name itself?
Yes, as documented in the Javadoc of the @Bean
annotation:
the default strategy for determining the name of a bean is to use the name of the @Bean method
That said, it should be noted that there is a difference between the Spring bean name and the Spring Batch job/step name (those can be different):
@Bean
public Job job(JobBuilderFactory jobBuilderFactory) {
return jobBuilderFactory.get("myJob")
//...
.build();
}
In this example, the Spring bean name is job
and the Spring Batch job name is myJob
.