Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Batch default beans not included

I only use annotation driven configuration, no XML hell, including a spring batch application into my spring mvc rest based application.

The spring-batch configuration file starts like this:

@Configuration
@EnableBatchProcessing
public class BatchConfig {

    @Autowired
    JobBuilderFactory jobBuilderFactory;

    @Autowired
    StepBuilderFactory stepBuilderFactory;
[...]

IntelliJ puts a mark on those beans, telling me it could not autowire as no beans of 'JobBuilderFactory' / 'StepBuilderFactory' type were found. AFAIK the annotation @EnableBatchProcessing should make those beans available.

The application does compile, so spring-batch seems to be included. In my pom.xml I added

<dependency>
    <groupId>org.springframework.batch</groupId>
    <artifactId>spring-batch-core</artifactId>
    <version>3.0.2.RELEASE</version>
</dependency>

I can autowire other beans (private Environment environment) in the same file, so autowiring itself works. Which steps do i need to find the solution? Could it only be an Intellij issue as it compiles?

like image 911
dexBerlin Avatar asked Jan 24 '26 04:01

dexBerlin


1 Answers

EnableBatchProcessing annotation need to be added along with @Configration

@Configuration
@EnableBatchProcessing
public class BatchConfiguration {
    @Autowired
    public JobBuilderFactory jobBuilderFactory;

    @Autowired
    public StepBuilderFactory stepBuilderFactory;

}
like image 143
Anil Konduru Avatar answered Jan 25 '26 23:01

Anil Konduru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!