JAVA-3570: Update to Spring Batch 4.3 and update config accordingly in spring-batch
This commit is contained in:
parent
e2026cf43e
commit
84a14bcaeb
|
@ -95,8 +95,8 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring.version>5.2.0.RELEASE</spring.version>
|
<spring.version>5.3.0</spring.version>
|
||||||
<spring.batch.version>4.2.0.RELEASE</spring.batch.version>
|
<spring.batch.version>4.3.0</spring.batch.version>
|
||||||
<sqlite.version>3.15.1</sqlite.version>
|
<sqlite.version>3.15.1</sqlite.version>
|
||||||
<opencsv.version>4.1</opencsv.version>
|
<opencsv.version>4.1</opencsv.version>
|
||||||
<jaxb.version>2.3.1</jaxb.version>
|
<jaxb.version>2.3.1</jaxb.version>
|
||||||
|
|
Binary file not shown.
|
@ -1,12 +1,5 @@
|
||||||
package com.baeldung.batchscheduler;
|
package com.baeldung.batchscheduler;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.IdentityHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import com.baeldung.batchscheduler.model.Book;
|
import com.baeldung.batchscheduler.model.Book;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -20,7 +13,7 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor
|
||||||
import org.springframework.batch.core.launch.JobLauncher;
|
import org.springframework.batch.core.launch.JobLauncher;
|
||||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||||
import org.springframework.batch.core.repository.JobRepository;
|
import org.springframework.batch.core.repository.JobRepository;
|
||||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
|
||||||
import org.springframework.batch.item.ItemWriter;
|
import org.springframework.batch.item.ItemWriter;
|
||||||
import org.springframework.batch.item.file.FlatFileItemReader;
|
import org.springframework.batch.item.file.FlatFileItemReader;
|
||||||
import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder;
|
import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder;
|
||||||
|
@ -30,12 +23,22 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
import org.springframework.scheduling.support.ScheduledMethodRunnable;
|
import org.springframework.scheduling.support.ScheduledMethodRunnable;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableBatchProcessing
|
@EnableBatchProcessing
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@ -122,9 +125,18 @@ public class SpringBatchScheduler {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JobRepository jobRepository() throws Exception {
|
public JobRepository jobRepository() throws Exception {
|
||||||
MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
|
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
|
||||||
|
factory.setDataSource(dataSource());
|
||||||
factory.setTransactionManager(new ResourcelessTransactionManager());
|
factory.setTransactionManager(new ResourcelessTransactionManager());
|
||||||
return (JobRepository) factory.getObject();
|
return factory.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DataSource dataSource() {
|
||||||
|
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
|
dataSource.setDriverClassName("org.sqlite.JDBC");
|
||||||
|
dataSource.setUrl("jdbc:sqlite:repository.sqlite");
|
||||||
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor
|
||||||
import org.springframework.batch.core.launch.JobLauncher;
|
import org.springframework.batch.core.launch.JobLauncher;
|
||||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||||
import org.springframework.batch.core.repository.JobRepository;
|
import org.springframework.batch.core.repository.JobRepository;
|
||||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
|
||||||
import org.springframework.batch.item.ItemProcessor;
|
import org.springframework.batch.item.ItemProcessor;
|
||||||
import org.springframework.batch.item.ItemReader;
|
import org.springframework.batch.item.ItemReader;
|
||||||
import org.springframework.batch.item.ItemWriter;
|
import org.springframework.batch.item.ItemWriter;
|
||||||
|
@ -21,8 +21,11 @@ import org.springframework.batch.test.JobLauncherTestUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableBatchProcessing
|
@EnableBatchProcessing
|
||||||
public class ChunksConfig {
|
public class ChunksConfig {
|
||||||
|
@ -38,9 +41,18 @@ public class ChunksConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JobRepository jobRepository() throws Exception {
|
public JobRepository jobRepository() throws Exception {
|
||||||
MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
|
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
|
||||||
|
factory.setDataSource(dataSource());
|
||||||
factory.setTransactionManager(transactionManager());
|
factory.setTransactionManager(transactionManager());
|
||||||
return (JobRepository) factory.getObject();
|
return factory.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DataSource dataSource() {
|
||||||
|
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
|
dataSource.setDriverClassName("org.sqlite.JDBC");
|
||||||
|
dataSource.setUrl("jdbc:sqlite:repository.sqlite");
|
||||||
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -11,14 +11,17 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor
|
||||||
import org.springframework.batch.core.launch.JobLauncher;
|
import org.springframework.batch.core.launch.JobLauncher;
|
||||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||||
import org.springframework.batch.core.repository.JobRepository;
|
import org.springframework.batch.core.repository.JobRepository;
|
||||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
|
||||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableBatchProcessing
|
@EnableBatchProcessing
|
||||||
public class TaskletsConfig {
|
public class TaskletsConfig {
|
||||||
|
@ -34,9 +37,18 @@ public class TaskletsConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JobRepository jobRepository() throws Exception {
|
public JobRepository jobRepository() throws Exception {
|
||||||
MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
|
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
|
||||||
|
factory.setDataSource(dataSource());
|
||||||
factory.setTransactionManager(transactionManager());
|
factory.setTransactionManager(transactionManager());
|
||||||
return (JobRepository) factory.getObject();
|
return factory.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DataSource dataSource() {
|
||||||
|
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
|
dataSource.setDriverClassName("org.sqlite.JDBC");
|
||||||
|
dataSource.setUrl("jdbc:sqlite:repository.sqlite");
|
||||||
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
Loading…
Reference in New Issue