How Does Spring Batch Step Scope Work

A spring batch StepScope object is one which is unique to a specific step and not a singleton. As you probably know, the default bean scope in Spring is a singleton. But by specifying a spring batch component being StepScope means that Spring Batch will use the spring container to instantiate a new instance of … Read more

Spring Batch Framework – Auto create Batch Table

UPDATE: As of spring 2.5.0, you should use spring.batch.jdbc.initialize-schema instead. See source. With Spring Boot 2.0 you probably need this: https://docs.spring.io/spring-boot/docs/2.0.0.M7/reference/htmlsingle/#howto-initialize-a-spring-batch-database spring.batch.initialize-schema=always By default it will only create the tables if you are using an embedded database. Or spring.batch.initialize-schema=never To permanently disable it.

How Spring Boot run batch jobs

The jobs execution can be prevented by setting spring.batch.job.enabled=false in application.properties. Or you can use spring.batch.job.names it takes a comma-delimited list of job names that will be run. Taken from here: how to stop spring batch scheduled jobs from running at first time when executing the code?

How to java-configure separate datasources for spring batch data and business data? Should I even do it?

Ok, this is strange but it works. Moving the datasources to it’s own configuration class works just fine and one is able to autowire. The example is a multi-datasource version of Spring Batch Service Example: DataSourceConfiguration: public class DataSourceConfiguration { @Value(“classpath:schema-mysql.sql”) private Resource schemaScript; @Bean @Primary public DataSource hsqldbDataSource() throws SQLException { final SimpleDriverDataSource dataSource … Read more

Spring-Batch without persisting metadata to database?

Simply create a configuration without datasource for Batch configuration : @Configuration @EnableAutoConfiguration @EnableBatchProcessing public class BatchConfiguration extends DefaultBatchConfigurer { @Override public void setDataSource(DataSource dataSource) { // override to do not set datasource even if a datasource exist. // initialize will use a Map based JobRepository (instead of database) } } It will initialize JobRepository and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)