小编dar*_*ily的帖子

有没有办法解决Spring Batch中的OptimisticLockingFailureException?

我有一个 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)

java spring-batch spring-boot

5
推荐指数
0
解决办法
1173
查看次数

@EnableJpaRepositories 未检测到,或者在 spring-boot 应用程序中的任何位置均未检测到 Repository 的 @Autowired

我已经提到了许多与此类似的 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)

java spring-data-jpa

3
推荐指数
1
解决办法
5万
查看次数

标签 统计

java ×2

spring-batch ×1

spring-boot ×1

spring-data-jpa ×1