简体   繁体   English

在Spring Batch 3.0.x中-如何为非标准数据库设置数据库类型?

[英]In Spring Batch 3.0.x - How to set database type for Non-standard Database?

Using the previous xml format, it can be achieved by following ways:- (1) 使用以前的xml格式,可以通过以下方式实现:-(1)

<value>classpath:batch-mysql.properties</value>

(2) (2)

<bean id="jobRepository" class="org...JobRepositoryFactoryBean">
<property name="databaseType" value="mysql"/>
<property name="dataSource" ref="dataSource"/>

[Reference: http://docs.spring.io/spring-batch/reference/html/configureJob.html] [参考: http//docs.spring.io/spring-batch/reference/html/configureJob.html]

I was able to work with database using spring batch previous format xml. 我能够使用Spring Batch以前的格式xml处理数据库。 But I am stuck with the new format annotation. 但是我坚持使用新的格式注释。 It is by default always using the embedded hsql. 默认情况下,始终使用嵌入式hsql。

But with the new format (using annotations only) how to set the database type? 但是使用新格式(仅使用注释)如何设置数据库类型?

There is not much information in the API document regarding this. API文档中关于此的信息不多。

Could someone help me on this? 有人可以帮我吗? Thanks. 谢谢。

After trying out couple of things. 在尝试了几件事之后。 Figured out a way to achieve setting database type (May not be the efficient way). 想出一种方法来设置数据库类型(可能不是有效的方法)。 I am using - 我在用 -

HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
jpaVendorAdapter.setDatabase(Database.MYSQL); 

It is working. 这是工作。 My code is available here - http://github.com/sidnan/spring-batch-example . 我的代码在这里-http://github.com/sidnan/spring-batch-example If anyone got anything better please let me know. 如果有人有更好的东西,请告诉我。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM