我試圖創建一個Spring Batch的應用Spring Batch的。我們使用SQL Anywhere數據庫,該數據庫實際上是SQLSERVER
,這是一種已知的數據庫類型。爲了讓事情我使用@SpringBootApplication
我的主類和@EnableBatchProcessing
更容易在我的配置類。使用帶有自動配置和非標準數據庫
的問題是,我的數據庫驅動程序,sybase.jdbc4.sqlanywhere.IDriver
,返回一個產品名稱「SQL Anywhere的」,這是不被認可的春天,導致各種錯誤。我能夠在我的配置類明確創建JobRepositoryFactoryBean讓過去一些:
/**
* We can't rely on Spring Boot as it can't set the database type properly.
*
* By explicitly requiring the arguments in the constructor, we force the Autowiring
* to occur.
*/
@Bean
public JobRepositoryFactoryBean jobRepositoryFactory(DataSource ds, PlatformTransactionManager tm) {
JobRepositoryFactoryBean jf = new JobRepositoryFactoryBean();
jf.setDataSource(ds);
jf.setTransactionManager(tm);
jf.setDatabaseType("SQLSERVER");
jf.setTablePrefix("DBA.BATCH_");
jf.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE"); // only one instance at a time
return jf;
}
然而,DefaultBatchConfigurer
未能在intialize功能,因爲它明確地構建自己的JobExplorerFactoryBean。
我想知道是否有一些簡單的解決方法,或者我將不得不復制DefaultBatchConfigurer
類中的工作,並自己定義所有bean並刪除@EnableBatchProcessing
註釋。