我有一个 Spring Batch 配置。
@Bean(BatchJobConstant.WITHDRAW_BATCH_JOB)
public Job importJob(@Qualifier(BatchJobConstant.CUSTOM_READER) CustomListItemReader<WithdrawDetails> reader,
@Qualifier(BatchJobConstant.CUSTOM_WRITER) ItemWriter<WithdrawDetails> writer,
@Qualifier(BatchJobConstant.CUSTOM_PROCESSOR) ItemProcessor<WithdrawDetails,
WithdrawDetails> processor,
@Qualifier(BatchJobConstant.POOL_TASK_EXECUTOR) TaskExecutor taskExecutor) {
final Step writeToDatabase = stepBuilderFactory.get(BatchJobConstant.WITHDRAW_BATCH_STEP)
.<WithdrawDetails, WithdrawDetails>chunk(chunkSize)
.reader(reader)
.processor(processor)
.writer(writer)
.transactionManager(transactionManager)
.taskExecutor(taskExecutor)
.throttleLimit(throttleLimit)
.build();
return jobBuilderFactory.get(BatchJobConstant.WITHDRAW_JOB_BUILDER_FACTORY)
.incrementer(new RunIdIncrementer())
.start(writeToDatabase)
.build();
}
Run Code Online (Sandbox Code Playgroud)
自定义阅读器如下:
public class CustomListItemReader<T> implements ItemReader<T> {
private List<T> list;
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
log.debug("Set list of size {}", list.size());
if (AopUtils.isAopProxy(list)) {
this.list = list;
} else {
this.list …Run Code Online (Sandbox Code Playgroud) 我已经提到了许多与此类似的 stackoverflow 问题。我已尝试了提供的所有解决方案和建议。但由于未检测到 Repository 类的 @Autowired,无论其在 Boot 应用程序文件中的 @EnableJpaRepositories 中的定义如何,都会不断给出错误。我尝试过使用
@Configuration
@EnableAutoConfiguration
@ComponentScan("com.example.repository") as well in the Boot application class.
Nothing seems to resolve the error.
Desperately seeking help from anyone who can find out what am I doing wrong. Please help me out. I have been trying to find on the internet and tried on my own. But still no luck and I have not been patient for the past two days because of this.
I want to resolve …Run Code Online (Sandbox Code Playgroud)