具有单个数据源的SpringBoot +批处理+ Cloud Task @EnableTask注释导致“序列不存在”问题

问题描述

当前,我正在将SpringBoot(2.3.3版)和Batch(4.2.4版)以及spring-cloud-starter-tsk(2.2.3版)与单个数据源(oracle)结合使用。我的BatchConfiguration扩展了DefaultBatchConfigurer并设置了setDataSource。现在,我尝试连接Oracle数据库并读取记录并生成平面文件

我遇到了错误,奇怪的是我能够获得数据源,并且SEQUENCE(TASK_SEQ)在DB中可用。

enter image description here

请在下面找到我的其他文件

  • BatchConfiguraton.java是

enter image description here

  • Application.java是

    enter image description here

-application.yml是

enter image description here

解决方法

在批处理配置中,您正在使用MapJobRepositoryFactoryBean来创建基于Map的JobRepository内存。您需要删除它,并按照参考文档Configuring a JobRepository中的说明使用指向您的Oracle数据源的基于JDBC的作业存储库。

在运行作业之前,您需要确保在Oracle数据库中创建了Spring Batch元数据表。

对于Spring Cloud Task也应进行相同的配置。