Giriş
Şu satırı dahil ederiz
Şu satırı dahil ederiz
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
JobRepository nesnesi yaratır
Şöyle yaparız
@Beanpublic JobRepository hazelCastJobRepo(DataSource dataSource,HazelcastTransactionManager hazelcastTransactionManager) {JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();jobRepositoryFactoryBean.setDataSource(dataSource);jobRepositoryFactoryBean.setDatabaseType("POSTGRES");jobRepositoryFactoryBean.setTransactionManager(hazelcastTransactionManager);return jobRepositoryFactoryBean.getObject();}
Örnek
Şöyle yaparız
@Autowired private DataSource dataSource; @Bean public JobRepository jobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(dataSource); factory.setTransactionManager(transactionManager()); factory.afterPropertiesSet(); return factory.getObject(); } @Bean public PlatformTransactionManager transactionManager() { return new DataSourceTransactionManager(dataSource); } @Bean public JobLauncher jobLauncher() throws Exception { SimpleJobLauncher launcher = new SimpleJobLauncher(); launcher.setJobRepository(jobRepository()); launcher.setTaskExecutor(new SimpleAsyncTaskExecutor()); launcher.afterPropertiesSet(); return launcher; }
Hiç yorum yok:
Yorum Gönder