SpringBoot + Batch + Cloud Task @EnableTask annotation with single datasource causes "Sequence does not exist" Issue

huangapple go评论76阅读模式
英文:

SpringBoot + Batch + Cloud Task @EnableTask annotation with single datasource causes "Sequence does not exist" Issue

问题

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

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

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

  • BatchConfiguraton.java 如下:
// 代码部分,不翻译
  • Application.java 如下:
// 代码部分,不翻译

-application.yml 如下:

// 代码部分,不翻译
英文:

Currently I'm using the SpringBoot ( 2.3.3 Version ) and Batch ( 4.2.4 Version ) and spring-cloud-starter-tsk ( 2.2.3 Version ) with Single Datasource ( oracle ). My BatchConfiguration extends the DefaultBatchConfigurer and made setDataSource. Now I'm trying to connect the Oracle DB and read records & generate the flatfile.

I'm getting below error and strange thing is I'm able to get the datasource and SEQUENCE (TASK_SEQ ) is available in DB.

SpringBoot + Batch + Cloud Task @EnableTask annotation with single datasource causes "Sequence does not exist" Issue

Please find my other files below

  • BatchConfiguraton.java is

SpringBoot + Batch + Cloud Task @EnableTask annotation with single datasource causes "Sequence does not exist" Issue

  • Application.java is
    SpringBoot + Batch + Cloud Task @EnableTask annotation with single datasource causes "Sequence does not exist" Issue

-application.yml is
SpringBoot + Batch + Cloud Task @EnableTask annotation with single datasource causes "Sequence does not exist" Issue

答案1

得分: 2

在您的批处理配置中,您正在使用 MapJobRepositoryFactoryBean,它会在内存中创建基于映射的作业存储库。您需要将其移除,并按照参考文档中的说明,使用指向您的 Oracle 数据源的基于 JDBC 的作业存储库:配置 Job 存储库

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

同样的配置也适用于 Spring Cloud Task。

英文:

In your batch configuration, you are using the MapJobRepositoryFactoryBean which creates a Map-based JobRepository in-memory. You need to remove this and use the JDBC based job repository pointing to your Oracle datasource as described in the reference documentation: Configuring a JobRepository.

You need to make sure that Spring Batch meta-data tables are created in your Oracle database before running your job.

The same configuration should be done for Spring Cloud Task as well.

huangapple
  • 本文由 发表于 2020年9月26日 23:30:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/64079443.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定