当前位置: 首页 > 知识库问答 >
问题:

有没有人尝试过实现一个不受支持的数据库来用于Spring批处理的jobRepository?

松和泰
2023-03-14

Spring批处理不支持我的数据库Sap Hana db。我正在寻找一个关于如何为SpringBatch实现我自己的SimpleJobRepository的DAO的指南。以前试过吗?

我没有包含数据库类型属性,因为根据spring batch网站,不包含它将自动搜索数据库类型。我还使用了JobRepositoryFactoryBean,因为db不受支持。

我很高兴能为这个写我自己的实现,也许我可以把它贡献给spring批处理源代码。

我的设置如下:

   <bean id="jobRepository"
        class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="isolationLevelForCreate" value="ISOLATION_DEFAULT" />
        <property name="validateTransactionState" value="false"/>
    </bean> 

当前我收到以下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository' defined in ServletContext resource [/WEB-INF/batch-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: DatabaseType not found for product name: [HDB]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
    ... 59 more
Caused by: java.lang.IllegalArgumentException: DatabaseType not found for product name: [HDB]
    at org.springframework.batch.support.DatabaseType.fromProductName(DatabaseType.java:79)
    at org.springframework.batch.support.DatabaseType.fromMetaData(DatabaseType.java:110)
    at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:182)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 66 more

共有1个答案

郭俊人
2023-03-14

Spring Batch3提供了注入自定义数据库类型的机会。检查DatabaseType和JobRepositoryFactotyBean.setDatabaseType()(而不是让SB从datasource自动检测数据库类型)。
当然,您需要为创建元数据表创建脚本(使用此博文作为示例和正式文档)

 类似资料:
  • 我正在尝试更改现有的spring批处理作业(XML配置),它从oracle数据库读取数据,并以所需格式写入txt和XML文件,但现在我想更改相同的实现,从Cassandra数据库而不是oracle读取数据,但我在spring批处理中找不到类似于JdbcCursorItemReader的项目读取器。 有人能告诉我应该使用哪个ItemReader从Cassandra DB读取数据吗?或者我需要创建一个

  • 我使用Spring批处理从Oracle数据库读取数据并将结果写入CSV文件。 我还需要将spring批处理元数据表与oracle数据库分开,为此,我在批处理配置中配置了两个不同的数据源(spring批处理元数据的内存数据库)。 这是我的代码: 批处理配置。JAVA 然后我的itemReader bean看起来像: 当我运行批处理时,一切正常。 但是当我尝试在我的BatchApplication中添

  • 我试图在Spring批处理作业中使用多线程步骤,但我得到一个“范围‘作业’对于当前线程不活动……”。我在Spring中尝试了几种方法,但目前我正在使用我认为是OOTB Spring构造的方法,但仍然失败。 错误是: 基本作业结构简化:作业SoftLayerUpload作业步骤:softlayerUploadFileStep(不能多线程)从Excel文件读取写入SoftLayerDataItemQu

  • 这是我给管理员的yaml: 这是我给mongoDB的名字 所以我的问题是,我无法登录mongod,因为我从Adminer获得了这个信息:Adminer不支持在没有密码的情况下访问数据库。这个问题有没有简单的解决方法,我可以登录到我的mongod?还有,我经营库伯尼特斯

  • 这似乎是一个愚蠢的问题。我正在尝试为Spring Batch作业存储库(Spring Batch 2.1.7)配置Oracle10g数据库,我能够使用在core中的org/spring框架/批/core/schema-oracle10g.sql可用的脚本创建表。我还将属性batch.data.source.init设置为false。 在干净的数据库上,我的批处理程序运行良好,成功地创建了所有批处理

  • 我的系统有三个数据源,都以名为datasourceA、datasourceB、datasourceC的bean的形式公开。我试图将spring batch的数据源设置为datasourceB,但我遇到了一些问题。 我的Spring班 在这个设置中,我在启动时会遇到这个错误 我无法将我的任何数据源设置为@Prime,因为我的Spring批处理编写器使用所有3个数据源进行读取和写入。我正在使用JPA存