Spring Batch使用不支持的数据库
·
开发任务将oracle转为达梦,然而spring Batch并不支持。会报DatabaseType找不到
我们也可以从源码中看出DatabaseType这个枚举并没有达梦

https://docs.spring.io/spring-batch/docs/current/reference/html/index-single.html#repeat
官方手册大概应该是使用接近数据源的数据库(博主英文不好)
@Configuration
@EnableBatchProcessing
public class BatchConfiguration extends DefaultBatchConfigurer {
@Autowired
private DataSource dataSource;
@Autowired
private PlatformTransactionManager platformTransactionManager;
@Override
protected JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean factoryBean = new JobRepositoryFactoryBean();
factoryBean.setDatabaseType(DatabaseType.H2.getProductName());
factoryBean.setDataSource(dataSource);
factoryBean.setTransactionManager(platformTransactionManager);
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
@Override
protected JobExplorer createJobExplorer() throws Exception {
JobExplorerFactoryBean factoryBean = new JobExplorerFactoryBean();
factoryBean.setDataSource(this.dataSource);
factoryBean.setTablePrefix("BATCH_");
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
}
在这里我数据类型改成H2
yml配置连接依旧是达梦保持不变。连接成功
DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐



所有评论(0)