无法自动连接spring批处理itemreader、writer

qcuzuvrc  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(234)

我正试图创建一个批处理配置类,但无法将此字段注入idk为什么类注解:

@Configuration
@EnableBatchProcessing
@Component
public class SpringBatchConfig {

and here is code 

     @Bean
    public Job job(JobBuilderFactory jobBuilderFactory,
                   StepBuilderFactory stepBuilderFactory,
                   ItemReader<Object> personItemReader,
                   ItemProcessor<Object, Person> itemProcessor,
                   ItemWriter<Object> personItemWriter
                   ){

        Step step = stepBuilderFactory.get("ETL-File-Load")
                .chunk(100)
                .reader(personItemReader)
                .writer(personItemWriter)
                .build();
        Job job = jobBuilderFactory.get("ETL-Load")
                .incrementer(new RunIdIncrementer())
                .start(step)
                .build();

    return job;

这就是全部错误:

Parameter 2 of method job in com.emir.batchjobtest.config.SpringBatchConfig required a bean of type 'org.springframework.batch.item.ItemReader' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.batch.item.ItemReader' in your configuration.

Process finished with exit code 0

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题