mirror of
https://github.com/spring-projects/spring-batch.git
synced 2024-07-04 23:36:46 +08:00
Updated Spring Batch 5.0 Migration Guide (markdown)
parent
3ab8670ddf
commit
6b32131df9
@ -81,6 +81,7 @@ As a result of the aforementioned issue, and in combination with the inconsisten
|
||||
The typical migration path from v4 to v5 in that regard is as follows:
|
||||
|
||||
```
|
||||
@Configuration
|
||||
@EnableBatchProcessing
|
||||
public class MyStepConfig {
|
||||
|
||||
@ -100,6 +101,53 @@ public class MyStepConfig {
|
||||
|
||||
This is only required for tasklet steps, other step types do not require a transaction manager by design.
|
||||
|
||||
### JobBuilderFactory and StepBuilderFactory bean exposure/configuration
|
||||
|
||||
`JobBuilderFactory` and `StepBuilderFactory` are not exposed as beans in the application context anymore, and are now deprecated for removal in v5.2 in favor of using the respective builders they create.
|
||||
|
||||
The typical migration path from v4 to v5 in that regard is as follows:
|
||||
|
||||
```
|
||||
// Sample with v4
|
||||
@Configuration
|
||||
@EnableBatchProcessing
|
||||
public class MyJobConfig {
|
||||
|
||||
@Autowired
|
||||
private JobBuilderFactory jobBuilderFactory;
|
||||
|
||||
@Bean
|
||||
public Job myJob(Step step) {
|
||||
return this.jobBuilderFactory.get("myJob")
|
||||
.start(step)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
// Sample with v5
|
||||
@Configuration
|
||||
@EnableBatchProcessing
|
||||
public class MyJobConfig {
|
||||
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Bean
|
||||
public Job myJob(Step step) {
|
||||
return new JobBuilder("myJob")
|
||||
.repository(this.jobRepository)
|
||||
.start(step)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The same pattern can be used to remove the usage of the deprecated `StepBuilderFactory`. For more details about this change, please check https://github.com/spring-projects/spring-batch/issues/4188.
|
||||
|
||||
### Default transaction manager type
|
||||
|
||||
When no transaction manager is specified, `@EnableBatchProcessing` used (up to version 4.3) to register a default transaction manager of type `org.springframework.jdbc.datasource.DataSourceTransactionManager` in the proxy around `JobRepository` when a `DataSource` bean is defined in the application context. In this release, the type of the default transaction manager has changed to `org.springframework.jdbc.support.JdbcTransactionManager`.
|
||||
|
Loading…
Reference in New Issue
Block a user