有没有人尝试实现不受支持的数据库以用于Spring Batch的jobRepository? [英] Has anyone tried implementing a unsupported database to use for jobRepository for Spring Batch?

查看:231
本文介绍了有没有人尝试实现不受支持的数据库以用于Spring Batch的jobRepository?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Batch不支持我的数据库Sap Hana db.我正在寻找有关如何为SpringBatch的SimpleJobRepository实现自己的DAO的指南.曾经尝试过吗?

My database Sap Hana db is not supported for Spring Batch. I am looking for a guide on how to implement my own DAOs for SimpleJobRepository for SpringBatch. Has tried this before?

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

I did not include the database type property because according to spring batch website not including it will auto search for a database type. I also used JobRepositoryFactoryBean since the db is unsupported.

我很高兴为此编写自己的实现,也许我可以为 春季批处理源.

I am excited though to write my own implementation for this, maybe i can contribute it to spring batch source.

我的设置如下:

   <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

推荐答案

Spring Batch 3提供了注入自定义数据库类型的机会. 检查 DatabaseType 博文中的示例和官方文档)

Spring Batch 3 offers the opportunity to inject custom database types. Check DatabaseType and JobRepositoryFactotyBean.setDatabaseType() (instead of let SB autodetect database type from datasource).
Of course you need to create scripts for metadata tables creation (use this blog post for an example and official doc)

这篇关于有没有人尝试实现不受支持的数据库以用于Spring Batch的jobRepository?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆