Â
é ãã°ããªãããSpringBatch4ç³»ãã5ç³»ã«ã¢ããã°ã¬ã¼ããçºçããããªã®ã§ãèªåç¨ã¡ã¢ã
Â
spring-projectsã®spring-batchã®Spring Batch 5.0 Migration Guideã¯è±èªãªã®ã§ãå訳ããªãããã³ã¡ã³ããã¤ãã¦ãããã¨ã§ãç解ãã¦ããã
Â
- JDK 17 baseline
- Dependencies upgrade
- Database schema update
- Infrastructure beans configuration with @EnableBatchProcessing
- Data types updates
- Observability updates
- Execution context serialization updates
- SystemCommandTasklet updates
- Job parameters handling updates
- Default job parameter conversion
- Historical data access implications
- Deprecated APIs
- Moved APIs
- Removed APIs
- Pruning
- SQLFire support removal
- JSR-352 implementation removal
- Gemfire support removal
- æå¾ã«
Â
JDK 17 baseline
Spring Batch 5 is based on Spring Framework 6 which requires Java 17 as a minimum version. Therefore, you need to use Java 17+ to run Spring Batch 5 applications.
ï¼å訳ï¼
JDK 17ãã¼ã¹ã©ã¤ã³
Spring Batch 5ã¯ãæå°ãã¼ã¸ã§ã³ã¨ãã¦Java 17ãå¿ è¦ã¨ããSpring Framework 6ã«åºã¥ãã¦ãã¾ãããããã£ã¦ãSpring Batch 5ã¢ããªã±ã¼ã·ã§ã³ãå®è¡ããã«ã¯ãJava 17 +ã使ç¨ããå¿ è¦ãããã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
Java17以ä¸ã使ã£ã¦ãã¨ãããã¨ã
Java17æªæºã§ããã°ãå ã«Javaã®ãã¼ã¸ã§ã³ã17以ä¸ã«ããå¿ è¦ãããã
Â
Dependencies upgrade
Spring Batch 5 is updating its Spring dependencies across the board to the following versions:
- Spring Framework 6
- Spring Integration 6
- Spring Data 3
- Spring AMQP 3
- Spring for Apache Kafka 3
- Micrometer 1.10
Moreover, this version marks the migration to:
- Jakarta EE 9: Please make sure to update your import statements fromÂ
javax.*
 toÂjakarta.*
 for all EE APIs you use.- Hibernate 6: Hibernate (cursor/paging) item readers and writer have been updated to use Hibernate 6.1 APIs (previously using Hibernate 5.6 APIs)
In addition to that:
org.springframework:spring-jdbc
 is now a required dependency inÂspring-batch-core
junit:junit
 is no more a required dependency inÂspring-batch-test
.com.fasterxml.jackson.core:jackson-core
 is now optional inÂspring-batch-core
ï¼å訳ï¼
ä¾åé¢ä¿ã®ã¢ããã°ã¬ã¼ã
Spring Batch 5ã§ã¯ãSpringã®ä¾åé¢ä¿ã以ä¸ã®ãã¼ã¸ã§ã³ã«å
¨é¢çã«æ´æ°ãã¦ããï¼
ã»Spring Framework 6
ã»Spring Integration 6
ã»Spring Data 3
ã»Spring AMQP 3
ã»Spring for Apache Kafka 3
ã»Micrometer 1.10
ããã«ããã®ãã¼ã¸ã§ã³ã¯ã以ä¸ã¸ã®ç§»è¡ãæå³ããï¼
Jakarta EE 9ï¼ä½¿ç¨ãããã¹ã¦ã®EE APIã«ã¤ãã¦ãimportæã javax.* ãã jakarta.* ã«æ´æ°ãã¦ãã ããã
Hibernate 6: Hibernateï¼ã«ã¼ã½ã«/ãã¼ã¸ã³ã°ï¼ã¢ã¤ãã ã»ãªã¼ãã¨ã©ã¤ã¿ããHibernate 6.1 APIã使ç¨ããããã«æ´æ°ããã¾ããï¼ä»¥åã¯Hibernate 5.6 APIã使ç¨ãã¦ãã¾ããï¼ã
追å ã§ä¸è¨ãããã¾ãã
org.springframework:spring-jdbcã¯ãspring-batch-coreã§å¿
é ã®ä¾åé¢ä¿ã«ãªãã¾ããã
junit:junitã¯spring-batch-testã®å¿
é ä¾åã§ã¯ãªããªãã¾ããã
com.fasterxml.jackson.core:jackson-coreã¯spring-batch-coreã®ãªãã·ã§ã³ã«ãªãã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»ãã¼ã¸ã§ã³ã®æ´æ°ã«ã¤ãã¦ã¯ãããããã©ãããç®çã®ãã¬ã¼ã ã¯ã¼ã¯ããåãããªæç¨ã«ãªã³ã¯ãå¼µã£ãã
Micrometerã¯ã¡ããªã¯ã¹ãã¼ã«ã§ãããã©ã«ãã§ãJVMãç¹å®ã®ãã°ãTomcatãExecutorServiceãHTTP Clientã®ã¡ããªã¯ã¹ãåå¾ã§ããã
ã»Jakarta EE 9ã«é¢ãã¦ã¯ãããããããimportæãæ¸ãæããå¿ è¦ãããã
ã»Hibernate 6.1 APIã¨Hibernate 5.6 APIã®éãã«ã¤ãã¦ã¯ãMigration Guideãå¼µã£ã¦ãããcursorãè¦ãéãã¯ã5.6ã¨6.1ã«ãããªã«éãããªãããï¼
ã»ä¾åé¢ä¿ç³»ã¯ãorg.springframework:spring-jdbcã¯å¿ é åãjunit:junitã¨com.fasterxml.jackson.core:jackson-coreã®ä¾åé¢ä¿ã軽ããªã£ãã
Â
Database schema update
ï¼å訳ï¼
ãã¼ã¿ãã¼ã¹ã¹ãã¼ãã®æ´æ°
Â
ï¼ã³ã¡ã³ãï¼
ã¡ãã£ã¨é·ãã®ã§ãDBæ¯ã«åå²ãã
Â
Oracle
In this version, Oracle sequences are now ordered. The sequences creation script has been updated for new applications. Existing applications can use the migration script inÂ
org/springframework/batch/core/migration/5.0/migration-oracle.sql
 to alter the existing sequences.Moreover, the DDL scripts for Oracle have been renamed as follows:
org/springframework/batch/core/schema-drop-oracle10g.sql
 has been renamed toÂorg/springframework/batch/core/schema-drop-oracle.sql
org/springframework/batch/core/schema-oracle10g.sql
 has been renamed toÂorg/springframework/batch/core/schema-oracle.sql
ï¼å訳ï¼
ãªã©ã¯ã«
ãã®ãã¼ã¸ã§ã³ã§ã¯ãOracleã·ã¼ã±ã³ã¹ãé çªã«ä¸¦ã¹ãããããã«ãªãã¾ãããã·ã¼ã±ã³ã¹ä½æã¹ã¯ãªãããæ°ããã¢ããªã±ã¼ã·ã§ã³ç¨ã«æ´æ°ããã¾ãããæ¢åã®ã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãorg/springframework/batch/core/migration/5.0/migration-oracle.sql ã«ãã移è¡ã¹ã¯ãªããã使ç¨ãã¦ãæ¢åã®ã·ã¼ã±ã³ã¹ãå¤æ´ã§ãã¾ãã
ããã«ãOracleç¨ã®DDLã¹ã¯ãªããã®ååã以ä¸ã®ããã«å¤æ´ããã¾ããï¼
org/springframework/batch/core/schema-drop-oracle10g.sql 㯠org/springframework/batch/core/schema-drop-oracle.sql ã«ååãå¤æ´ããã¾ããã
org/springframework/batch/core/schema-oracle10g.sql 㯠org/springframework/batch/core/schema-oracle.sql ã«ååãå¤æ´ããã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»ã·ã¼ã±ã³ã¹ã«é¢ããå¤æ´ããã£ãæ§åãã¾ããã¹ã¯ãªããåãå¤æ´ã
移è¡ã¹ã¯ãªãããå®è¡ããå¿ è¦ãããã®ã§ããªãªã¼ã¹ã¿ã¤ãã³ã°çã«å½±é¿ããããã
Â
MS SQLServer
Up until v4, the DDL script for MS SQLServer used tables to emulate sequences. In this version, this usage has been updated with real sequences:
CREATE SEQUENCE BATCH_STEP_EXECUTION_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CACHE NO CYCLE; CREATE SEQUENCE BATCH_JOB_EXECUTION_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CACHE NO CYCLE; CREATE SEQUENCE BATCH_JOB_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CACHE NO CYCLE;ÂNew applications can use the provided script with no modifications. Existing applications should consider modifying the snippet above to start sequences from the last value in sequence tables used with v4.
ï¼å訳ï¼
MS SQLServer
v4 ã¾ã§ã¯ãMS SQLServer ç¨ã® DDL ã¹ã¯ãªããã¯ã·ã¼ã±ã³ã¹ãã¨ãã¥ã¬ã¼ãããããã«ãã¼ãã«ã使ç¨ãã¦ãã¾ããããã®ãã¼ã¸ã§ã³ã§ã¯ããã®ä½¿ç¨æ³ãå®éã®ã·ã¼ã±ã³ã¹ã«æ´æ°ããã¾ããï¼
ï¼çç¥ï¼
æ°è¦ã¢ããªã±ã¼ã·ã§ã³ã¯ãæä¾ãããã¹ã¯ãªããã使ç¨ãããã¨ãã§ãã¾ãï¼
æ°ããã¢ããªã±ã¼ã·ã§ã³ã¯ãæä¾ãããã¹ã¯ãªãããä¿®æ£ãããã¨ãªã使ç¨ã§ãã¾ããæ¢åã®ã¢ããªã±ã¼ã·ã§ã³ã¯ãv4ã§ä½¿ç¨ãããã·ã¼ã±ã³ã¹ã»ãã¼ãã«ã®æå¾ã®å¤ããã·ã¼ã±ã³ã¹ãéå§ããããã«ãä¸è¨ã®ã¹ãããããä¿®æ£ãããã¨ãæ¤è¨ãã¦ãã ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»ãã¡ããã·ã¼ã±ã³ã¹ã®æ±ããå¤æ´ã
ã»ç¾ç¶ã«åããã¦ããã·ã¼ã±ã³ã¹ã»ãã¼ãã«ã®æå¾ã®å¤ããã·ã¼ã±ã³ã¹ãéå§ããããã®ã¯ãã¡ãã£ã¨é¢åã
Â
Â
All platforms
Removal ofÂ
BATCH_JOB_EXECUTION#JOB_CONFIGURATION_LOCATION
 columnThe columnÂ
JOB_CONFIGURATION_LOCATION
 in theÂBATCH_JOB_EXECUTION
 table is not used anymore and can be marked as unused or dropped if needed:ALTER TABLE BATCH_JOB_EXECUTION DROP COLUMN JOB_CONFIGURATION_LOCATION;
ÂThe syntax to drop the column might differ depending on the version of your database server, so please check the syntax of column deletion. This change might require a table reorganisation on some platforms.
â Important note â This change is mainly related to the removal of the JSR-352 implementation which was the only part of the framework using this column. As a consequence, the fieldÂ
JobExecution#jobConfigurationName
 has been removed as well as all APIs using it (constructors and getter in the domain objectÂJobExecution
, methodÂJobRepository#createJobExecution(JobInstance, JobParameters, String);
 inÂJobRepository
).
ï¼å訳ï¼
ãã¹ã¦ã®ãã©ãããã©ã¼ã
BATCH_JOB_EXECUTION#JOB_CONFIGURATION_LOCATIONåã®åé¤
BATCH_JOB_EXECUTIONãã¼ãã«ã®JOB_CONFIGURATION_LOCATIONåã¯ä½¿ç¨ãããªããªãã¾ããï¼
(çç¥)
ã«ã©ã ãåé¤ããæ§æã¯ãã¼ã¿ãã¼ã¹ãµã¼ãã¼ã®ãã¼ã¸ã§ã³ã«ãã£ã¦ç°ãªãå¯è½æ§ãããã®ã§ãã«ã©ã åé¤ã®æ§æã確èªãã¦ãã ããããã®å¤æ´ã«ããããã©ãããã©ã¼ã ã«ãã£ã¦ã¯ãã¼ãã«ã®åç·¨æãå¿ è¦ã«ãªãããããã¾ããã
â éè¦ãªæ³¨æâ ãã®å¤æ´ã¯ä¸»ã«ããã®ã«ã©ã ã使ç¨ãã¦ãããã¬ã¼ã ã¯ã¼ã¯ã®å¯ä¸ã®é¨åã§ãã£ã JSR-352 å®è£ ã®åé¤ã«é¢é£ãã¦ãã¾ãããã®çµæãJobExecution#jobConfigurationName ãã£ã¼ã«ããåé¤ãããããã使ç¨ãããã¹ã¦ã® APIï¼ãã¡ã¤ã³ãªãã¸ã§ã¯ã JobExecution ã®ã³ã³ã¹ãã©ã¯ã¿ã¨ã²ãã¿ã¼ãJobRepository#createJobExecution(JobInstance, JobParameters, String); in JobRepositoryï¼ãåé¤ããã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»BATCH_JOB_EXECUTIONã¯ãJobRepositoryã®ã¡ã¿ãã¼ã¿ãã¼ãã«ã®ä¸ã¤ãã¡ã¿ãã¼ã¿ãã¼ãã«ã«é¢ãã¦ã¯ãä¸è¨ãåç §ã
ã¡ã¿ãã¼ã¿ã¹ãã¼ã :: Spring Batch - ãªãã¡ã¬ã³ã¹
Spring Batchã®ã¢ã¼ããã¯ãã£
BATCH_JOB_EXECUTION.JOB_CONFIGURATION_LOCATIONãdropãã¦ãã¨ãããã¨ã
ã¾ããJobRepository#createJobExecution(JobInstance, JobParameters, String)ãåé¤ããã¦ããã®ã§ã注æã
ã»JSR-352ã«ã¤ãã¦ã¯ãJavaEEã®æ¨æºãããAPIã®ãã¨ãJobãChunkãStepã®ãããªæ¦å¿µã¯ãããããã¦ããã詳ããã¯ãä¸è¨ãåç §ã
Java EE ã®æ¨æºãããAPI -- JSR-352 Batch Applications for the Java Platform -- - A Memorandum
Â
Column change inÂ
BATCH_JOB_EXECUTION_PARAMS
TheÂ
BATCH_JOB_EXECUTION_PARAMS
 has been updated as follows:CREATE TABLE BATCH_JOB_EXECUTION_PARAMS ( JOB_EXECUTION_ID BIGINT NOT NULL , --- TYPE_CD VARCHAR(6) NOT NULL , --- KEY_NAME VARCHAR(100) NOT NULL , --- STRING_VAL VARCHAR(250) , --- DATE_VAL DATETIME(6) DEFAULT NULL , --- LONG_VAL BIGINT , --- DOUBLE_VAL DOUBLE PRECISION , +++ PARAMETER_NAME VARCHAR(100) NOT NULL , +++ PARAMETER_TYPE VARCHAR(100) NOT NULL , +++ PARAMETER_VALUE VARCHAR(2500) , IDENTIFYING CHAR(1) NOT NULL , constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID) references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) );ÂThis is related to the way job parameters are persisted as revisited in https://github.com/spring-projects/spring-batch/issues/3960. Migration scripts can be found inÂ
org/springframework/batch/core/migration/5.0
.
ï¼å訳ï¼
BATCH_JOB_EXECUTION_PARAMSã®ã«ã©ã å¤æ´
BATCH_JOB_EXECUTION_PARAMSã以ä¸ã®ããã«æ´æ°ããã¾ããï¼
(çç¥)
ããã¯ãhttps://github.com/spring-projects/spring-batch/issues/3960 ã§å確èªããããã«ãã¸ã§ããã©ã¡ã¼ã¿ãæ°¸ç¶åãããæ¹æ³ã«é¢é£ãã¦ãã¾ãã移è¡ã¹ã¯ãªããã¯org/springframework/batch/core/migration/5.0ã«ããã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
ã»BATCH_JOB_EXECUTION_PARAMSãJobRepositoryã®ã¡ã¿ãã¼ã¿ãã¼ãã«ã®ä¸ã¤ã
ãã¼ãã«å®ç¾©ã«å¤æ´ãããã®ã§ã移è¡ã¹ã¯ãªãããå©ç¨ããã¨ããã
Â
Â
Column change inÂ
BATCH_STEP_EXECUTION
A new columnÂ
CREATE_TIME
 was added in v5. You should create it in the table according to your database server, something like:ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00';ÂMoreover, theÂ
NOT NULL
 constraint was dropped from theÂSTART_TIME
 column:ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL;Â
ï¼å訳ï¼
BATCH_STEP_EXECUTIONã«ãããã«ã©ã ã®å¤æ´
v5ã§æ°ããã«ã©ã CREATE_TIMEã追å ãããï¼
(çç¥)
ããã«ãSTART_TIMEåããNOT NULLå¶ç´ãåé¤ãããï¼
(çç¥)
Â
ï¼ã³ã¡ã³ãï¼
ã»BATCH_STEP_EXECUTIONãJobRepositoryã®ã¡ã¿ãã¼ã¿ãã¼ãã«ã®ä¸ã¤ã
å®ç¾©ãå¤æ´ããã¦ããã®ã§ã使ç¨ç®æã®èª¿æ»å¯¾è±¡ã¨ãªãã
Â
Infrastructure beans configuration withÂ
@EnableBatchProcessing
ï¼å訳ï¼
EnableBatchProcessingã«ããã¤ã³ãã©ãã¼ã³ãºã®è¨å®
Â
ï¼ã³ã¡ã³ãï¼
ã»EnableBatchProcessingã¯Spring Boot ã® Spring Batch ã®èªåæ§æãæå¹ã«ããã¢ããã¼ã·ã§ã³ã
ãã®å¤æ´ãç ´å£çãªãã®ã§ããããã移è¡æã«ã¯æ³¨æãå¿
è¦ãªé¨åã
Spring Boot 3ã«ã¢ãããã¼ããããSpring Batchãåããªããªã£ã
Â
Job repository/explorer configuration updates
The Map-based job repository/explorer implementation were deprecated in v4 and completely removed in v5. You should use the Jdbc-based implementation instead. Unless you are using a custom Job repository/explorer implementation, theÂ
@EnableBatchProcessing
 annotation will configure a Jdbc-basedÂJobRepository
 which requires aÂDataSource
 bean in the application context. TheÂDataSource
 bean could refer to an embedded database like H2, HSQL, etc to work with an in-memory job repository
ï¼å訳ï¼
ã¸ã§ããªãã¸ããª/ã¨ã¯ã¹ããã¼ã©è¨å®ã®æ´æ°
Map ãã¼ã¹ã®ã¸ã§ãã»ãªãã¸ããª/ã¨ã¯ã¹ããã¼ã©ã®å®è£
㯠v4 ã§éæ¨å¥¨ã¨ãªããv5 ã§å®å
¨ã«åé¤ããã¾ããã 代ããã« Jdbc ãã¼ã¹ã®å®è£
ã使ç¨ããå¿
è¦ãããã¾ãã
ã«ã¹ã¿ã ã®ã¸ã§ããªãã¸ããª/ã¨ã¯ã¹ããã¼ã©å®è£ ã使ç¨ãã¦ããªãéãã@EnableBatchProcessing ã¢ããã¼ã·ã§ã³ã¯ã¢ããªã±ã¼ã·ã§ã³ã³ã³ããã¹ãã« DataSource Bean ãå¿ è¦ã¨ãã Jdbc ãã¼ã¹ã®ã¸ã§ããªãã¸ããªãæ§æãã¾ãã
DataSource Beanã¯H2ãHSQLãªã©ã®çµã¿è¾¼ã¿ãã¼ã¿ãã¼ã¹ãåç §ããã¤ã³ã¡ã¢ãªã¸ã§ããªãã¸ããªã¨é£æºãããã¨ãã§ãã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
ã»ä»ã¾ã§ã¡ã¿ãã¼ãã«ã«é¢ããæ å ±ã使ç¨ããªããã¨ãã§ããããä»åã®ãã¼ã¸ã§ã³ã¢ããã§ãã§ããªããªã£ãã
èãããã対å¿çã¨ãã¦ã¯ãâ è¨è¼ã®éãH2ãHSQLãªã©ã®çµã¿è¾¼ã¿ãã¼ã¿ãã¼ã¹ãå©ç¨ããããâ¡æ¢ã«åå¨ããDBã«ã¡ã¿ãã¼ãã«ãä½æãããã¨ã«ãªãããã
ã¡ãªã¿ã«ãH2ã«ã¤ãã¦ã¯ãææ°ãã¼ã¸ã§ã³ã ã¨ãã¡ã¨ããæ
å ±ãããã
Â
Â
Transaction manager bean exposure/configuration
Up until version 4.3, theÂ
@EnableBatchProcessing
 annotation exposed a tranasaction manager bean in the application context. While this was convenient in many cases, the unconditional exposure of a tranasaction manager could interfere with a user-defined transaction manager. In this release,Â@EnableBatchProcessing
 does not expose a transaction manager bean in the application context anymore. This change is related to issue https://github.com/spring-projects/spring-batch/issues/816.As a result of the aforementioned issue, and in combination with the inconsistency between the XML and Java config styles regarding the transaction manager that was fixed in https://github.com/spring-projects/spring-batch/issues/4130, it is now required to manually configure the transaction manager on any tasklet step definition. The methodÂ
StepBuilderHelper#transactionManager(PlatformTransactionManager)
 was moved down a level, toÂAbstractTaskletStepBuilder
.The typical migration path from v4 to v5 in that regard is as follows:
// Sample with v4 @Configuration @EnableBatchProcessing public class MyStepConfig { @Autowired private StepBuilderFactory stepBuilderFactory; @Bean public Step myStep() { return this.stepBuilderFactory.get("myStep") .tasklet(..) // or .chunk() .build(); } }
Â// Sample with v5 @Configuration @EnableBatchProcessing public class MyStepConfig { @Bean public Tasklet myTasklet() { return new MyTasklet(); } @Bean public Step myStep(JobRepository jobRepository, Tasklet myTasklet, PlatformTransactionManager transactionManager) { return new StepBuilder("myStep", jobRepository) .tasklet(myTasklet, transactionManager) // or .chunk(chunkSize, transactionManager) .build(); } }
ÂThis is only required for tasklet steps, other step types do not require a transaction manager by design.
Moreover, the transaction manager was configurable by implementingÂ
BatchConfigurer#getTransactionManager
. The transaction manager being an implementation detail of theÂJobRepository
, it should not be configurable at the same level as theÂJobRepository
 (ie in the same interface). In this release, theÂBatchConfigurer
 interface was removed. If needed, a custom transaction manager could be supplied either declaratively as an attribute ofÂ@EnableBatchProcessing
, or programmatically by overridingÂDefaultBatchConfiguration#getTransactionManager()
. For more details about this change, please check https://github.com/spring-projects/spring-batch/issues/3942.
ï¼å訳ï¼
ãã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ã»ãã¼ã³ã®å ¬é/æ§æ
ãã¼ã¸ã§ã³ 4.3 ã¾ã§ã¯ã@EnableBatchProcessing ã¢ããã¼ã·ã§ã³ã¯ã¢ããªã±ã¼ã·ã§ã³ã»ã³ã³ããã¹ãã§ãã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ Bean ãå
¬éãã¦ãã¾ãããããã¯å¤ãã®å ´åã«ä¾¿å©ã§ãããããã©ã³ã¶ã¯ã·ã§ã³ã»ããã¸ã£ã¼ãç¡æ¡ä»¶ã«å
¬éããã¨ãã¦ã¼ã¶ã¼å®ç¾©ã®ãã©ã³ã¶ã¯ã·ã§ã³ã»ããã¸ã£ã¼ã¨å¹²æ¸ããå¯è½æ§ãããã¾ããããã®ãªãªã¼ã¹ã§ã¯ã@EnableBatchProcessing ã¯ã¢ããªã±ã¼ã·ã§ã³ã»ã³ã³ããã¹ãã§ãã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ã»ãã¼ã³ãå
¬éãã¾ããããã®å¤æ´ã¯ãåé¡ https://github.com/spring-projects/spring-batch/issues/816 ã«é¢é£ãã¦ãã¾ãã
åè¿°ã®åé¡ã¨ãhttps://github.com/spring-projects/spring-batch/issues/4130 ã§ä¿®æ£ããããã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ã«é¢ãã XML æ§æã¹ã¿ã¤ã«ã¨ Java æ§æã¹ã¿ã¤ã«ã®ä¸ä¸è´ã®çµæã¨ãã¦ãã¿ã¹ã¯ã¬ããã»ã¹ãããå®ç¾©ã§ãã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ãæåã§æ§æããå¿ è¦ãããã¾ããStepBuilderHelper#transactionManager(PlatformTransactionManager)ã¡ã½ããã¯ãAbstractTaskletStepBuilderã«ã¬ãã«ãã¦ã³ããã¾ããã
v4ããv5ã¸ã®å ¸åçãªç§»è¡ãã¹ã¯ä»¥ä¸ã®éãã§ãï¼
(çç¥)
ããã¯ã¿ã¹ã¯ã¬ããã¹ãããã«ã®ã¿å¿ è¦ã§ãä»ã®ã¹ãããã¿ã¤ãã¯è¨è¨ä¸ãã©ã³ã¶ã¯ã·ã§ã³ããã¼ã¸ã£ã¼ãå¿ è¦ã¨ããªãã
ããã«ããã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ã¼ã¯BatchConfigurer#getTransactionManagerãå®è£ ãããã¨ã§è¨å®å¯è½ã§ãã£ãããã©ã³ã¶ã¯ã·ã§ã³ã»ããã¼ã¸ã£ã¼ã¯JobRepositoryã®å®è£ ã®è©³ç´°ã§ãããããJobRepositoryã¨åãã¬ãã«ã§ï¼ã¤ã¾ãåãã¤ã³ã¿ã¼ãã§ã¼ã¹ã§ï¼è¨å®ã§ããã¹ãã§ã¯ããã¾ããããã®ãªãªã¼ã¹ã§ã¯ãBatchConfigurer ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯åé¤ããã¾ãããå¿ è¦ã§ããã°ã@EnableBatchProcessingã®å±æ§ã¨ãã¦å®£è¨çã«ãã¾ãã¯DefaultBatchConfiguration#getTransactionManager()ããªã¼ãã¼ã©ã¤ããã¦ããã°ã©ã çã«ãã«ã¹ã¿ã ãã©ã³ã¶ã¯ã·ã§ã³ããã¼ã¸ã£ãæä¾ãããã¨ãã§ãã¾ãããã®å¤æ´ã®è©³ç´°ã«ã¤ãã¦ã¯ãhttps://github.com/spring-projects/spring-batch/issues/3942ã
Â
ï¼ã³ã¡ã³ãï¼
ã»TransactionManagerã®å¤æ´ã§ãã©ããã¦ãè¨å®ãå¤ãããå ´åã¯ãDefaultBatchConfiguration#getTransactionManager()ããªã¼ãã¼ã©ã¤ãããã¨ãããã¨ãåããã¦ãBatchConfigurerãåé¤ã
ã»ä¾ã®éãStepã®å®ç¾©ãå¤ãã£ã¦ãã¦ãå¼æ°ãå¤ãã£ã¦ããã®ã§ããã®è¾ºã®å¯¾å¿ãå¿ è¦ã
Â
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 { @Bean public Job myJob(JobRepository jobRepository, Step step) { return new JobBuilder("myJob", 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.
ï¼å訳ï¼
JobBuilderFactory 㨠StepBuilderFactory ãã¼ã³ã®å
¬é/è¨å®
JobBuilderFactoryã¨StepBuilderFactoryã¯ã¢ããªã±ã¼ã·ã§ã³ã³ã³ããã¹ãã§Beanã¨ãã¦å
¬éãããªããªããv5.2ã§ã¯åé¤ããã¾ããã
ãã®ç¹ã«é¢ããv4ããv5ã¸ã®å ¸åçãªç§»è¡ãã¹ã¯ä»¥ä¸ã®éãã§ãï¼
(çç¥)
åããã¿ã¼ã³ã使ã£ã¦ãéæ¨å¥¨ã®StepBuilderFactoryã®ä½¿ç¨ãåé¤ãããã¨ãã§ããããã®å¤æ´ã®è©³ç´°ã«ã¤ãã¦ã¯ãhttps://github.com/spring-projects/spring-batch/issues/4188ã
Â
ï¼ã³ã¡ã³ãï¼
ã»Jobã®å®ç¾©æ¹æ³ãå¤ãã£ããå¼æ°ã«jobRepositoryãå¢ãã¦ããã
ã»StepBuilderFactoryã®åé¤ã®ä¾ã¯ãTransaction manager bean exposure/configurationã®é ã«ããã®ã§ãåç §ãStepBuilderFactoryã¯åé¤ãã¦ããä½ã¨ããªãããã«ãªã£ãã
Â
Â
Data types updates
- Metric counters (
readCount
,ÂwriteCount
, etc) inÂorg.springframework.batch.core.StepExecution
 andÂorg.springframework.batch.core.StepContribution
 have been changed fromÂint
 toÂlong
. All getters and setters have been updated accordingly.- TheÂ
skipCount
 parameter inÂorg.springframework.batch.core.step.skip.SkipPolicy#shouldSkip
 has been changed fromÂint
 toÂlong
. This is related to the previous point.- The type of fieldsÂ
startTime
,ÂendTime
,ÂcreateTime
 andÂlastUpdated
 inÂJobExecution
 andÂStepExecution
 was changed fromÂjava.util.Date
 toÂjava.time.LocalDateTime
.
ï¼å訳ï¼
ãã¼ã¿åã®æ´æ°
org.springframework.batch.core.StepExecutionã¨org.springframework.batch.core.StepContributionã®ã¡ããªãã¯ã«ã¦ã³ã¿(readCount, writeCountãªã©)ãintããlongã«å¤æ´ããã¾ããããã¹ã¦ã®ã²ãã¿ã¼ã¨ã»ãã¿ã¼ã¯ããã«åããã¦æ´æ°ããã¾ããã
org.springframework.batch.core.step.skip.SkipPolicy#shouldSkipã®skipCountãã©ã¡ã¼ã¿ãintããlongã«å¤æ´ããããããã¯åã®ç¹ã¨é¢é£ãã¦ããã
JobExecutionã¨StepExecutionã®ãã£ã¼ã«ãstartTimeãendTimeãcreateTimeãlastUpdatedã®åãjava.util.Dateããjava.time.LocalDateTimeã«å¤æ´ãããã
Â
ï¼ã³ã¡ã³ãï¼
ã»åã®å¤æ´ãªã®ã§ãæ¢åããããããããã³ã³ãã¤ã«ã¨ã©ã¼ã«ãªãããã
Â
Observability updates
- Micrometer has been updated to version 1.10
- All tags are now prefixed with the meter name. For example, the tags of the timerÂ
spring.batch.job
 are namedÂname
 andÂstatus
 in version 4.x. In version 5, those tags are now namedÂspring.batch.job.name
 andÂspring.batch.job.status
 respectively.- TheÂ
BatchMetrics
 class (which is intended for internal use only) has been moved fromÂorg.springframework.batch.core.metrics
 to theÂorg.springframework.batch.core.observability
 package.
ï¼å訳ï¼
観測å¯è½æ§ã®æ´æ°
Micrometerããã¼ã¸ã§ã³1.10ã«æ´æ°ããã¾ããã
ãã¹ã¦ã®ã¿ã°ã®å
é ã«ã¡ã¼ã¿ã¼åãä»ãããã«ãªãã¾ãããä¾ãã°ãspring.batch.jobã¨ããã¿ã¤ãã¼ã®ã¿ã°ã¯ãã¼ã¸ã§ã³4.xã§ã¯nameã¨statusã¨ããååã§ãããããã¼ã¸ã§ã³5ã§ã¯ããããspring.batch.job.nameã¨spring.batch.job.statusã¨ããååã«ãªãã¾ããã
BatchMetricsã¯ã©ã¹(å
é¨ä½¿ç¨ã®ã¿)ã¯org.springframework.batch.core.metricsããorg.springframework.batch.core.observabilityããã±ã¼ã¸ã«ç§»åãã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»Micrometerã«é¢ããæ´æ°ã
Â
Execution context serialization updates
Starting from v5, the defaultÂ
ExecutionContextSerializer
 was changed fromÂJacksonExecutionContextStringSerializer
 toÂDefaultExecutionContextSerializer
. The default execution context serializer was updated to serialize/deserialize the context to/from Base64.The dependency to Jackson was made optional. In order to use theÂ
JacksonExecutionContextStringSerializer
,Âjackson-core
 should be added to the classpath.
ï¼å訳ï¼
å®è¡ã³ã³ããã¹ãã»ã·ãªã¢ã©ã¤ãºã®æ´æ°
v5 ãããããã©ã«ãã® ExecutionContextSerializer ã JacksonExecutionContextStringSerializer ãã DefaultExecutionContextSerializer ã«å¤æ´ããã¾ãããããã©ã«ãã®å®è¡ã³ã³ããã¹ãã»ã·ãªã¢ã©ã¤ã¶ã¼ãæ´æ°ãããã³ã³ããã¹ãã Base64 ã«ã·ãªã¢ã©ã¤ãº/Base64 ããã·ãªã¢ã©ã¤ãºè§£é¤ããããã«ãªãã¾ããã
Jackson ã¸ã®ä¾åé¢ä¿ããªãã·ã§ã³ã«ãªãã¾ãããJacksonExecutionContextStringSerializer ã使ç¨ããã«ã¯ãjackson-core ãã¯ã©ã¹ãã¹ã«è¿½å ããå¿ è¦ãããã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
ã»ExecutionContextSerializerã¯ãå®è¡ã³ã³ããã¹ãã®ç´ååã¨éç´ååã®ä¸¡æ¹ãåä¸ã®å®è£ ã«çµã¿åãããè¤åã¤ã³ã¿ã¼ãã§ã¼ã¹ã
Â
Â
SystemCommandTasklet updates
TheÂ
SystemCommandTasklet
 has been revisited in this release and was changed as follows:
A new strategy interface namedÂ
CommandRunner
 was introduced in order to decouple the command execution from the tasklet execution. The default implementation is theÂJvmCommandRunner
 which uses theÂjava.lang.Runtime#exec
 API to run system commands. This interface can be implemented to use any other API to run system commands.The method that runs the command now accepts an array ofÂ
String
s representing the command and its arguments. There is no need anymore to tokenize the command or do any pre-processing. This change makes the API more intuitive, and less prone to errors.
ï¼å訳ï¼
SystemCommandTasklet ã®ã¢ãããã¼ã
ä»åã®ãªãªã¼ã¹ã§ã¯ãSystemCommandTaskletãè¦ç´ããã以ä¸ã®ããã«å¤æ´ããã¾ããï¼
ã³ãã³ãã®å®è¡ãã¿ã¹ã¯ã¬ããã®å®è¡ããåãé¢ãããã« CommandRunner ã¨ããæ°ããã¹ãã©ãã¸ã¤ã³ã¿ãã§ã¼ã¹ãå°å ¥ããã¾ãããããã©ã«ãã®å®è£ ã¯JvmCommandRunnerã§ãjava.lang.Runtime#exec APIã使ã£ã¦ã·ã¹ãã ã³ãã³ããå®è¡ãã¾ãããã®ã¤ã³ã¿ãã§ã¼ã¹ã¯ãã·ã¹ãã ã³ãã³ããå®è¡ããããã«ä»ã®APIã使ç¨ããããã«å®è£ ãããã¨ãã§ãã¾ãã
ã³ãã³ããå®è¡ããã¡ã½ããã¯ãã³ãã³ãã¨ãã®å¼æ°ã表ãæååã®é åãåãåãã¾ããã³ãã³ãããã¼ã¯ã³åããããåå¦çããããããå¿ è¦ã¯ãªããªã£ãããã®å¤æ´ã«ãããAPIã¯ããç´æçã«ãªããã¨ã©ã¼ãçºçãã«ãããªãã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»SystemCommandTaskletã¯ãã®åã®éããã·ã¹ãã ã³ãã³ããå®è¡ããã¿ã¹ã¯ã¬ããã
Â
Â
Job parameters handling updates
ï¼å訳ï¼
ã¸ã§ãã»ãã©ã¡ã¼ã¿ã®æ´æ°
Â
ï¼ã³ã¡ã³ãï¼
ã»ããã®ãå¤ãã®ã§ãã»ã¯ã·ã§ã³ãã¨ã«ã«åããã
Â
Â
Support for any type as a job parameter
This change adds support to use any type as a job parameter, and not only the 4 pre-defined types (long, double, string, date) as in v4. The main change in the following:
---public class JobParameter implements Serializable { +++public class JobParameter<T> implements Serializable { --- private Object parameter; +++ private T value; --- private ParameterType parameterType; +++ private Class<T> type; }ÂWith this revision, theÂ
JobParameter
 can be of any type. This change required many API changes like changing the return type ofÂgetType()
, or the removal of theÂParameterType
 enum. All changes related to this update can be found in the "[Deprecated|Moved|Removed] APIs" sections.This change had an impact on how job parameters are persisted in the database (There are no more 4 distinct columns for each predefined type). Please check Column change in BATCH_JOB_EXECUTION_PARAMS for DDL changes. The fully qualified name of the type of the parameter is now persisted as aÂ
String
, as well as the parameter value. String literals are converted to the parameter type with the standard Spring conversion service. The standard conversion service can be enriched with any required converter to convert user specific types to and from String literals.
ï¼å訳ï¼
ã¸ã§ããã©ã¡ã¼ã¿ã¨ãã¦ã®ä»»æã®åã®ãµãã¼ã
ãã®å¤æ´ã«ãããv4ã®ããã«ãããããå®ç¾©ããã4ã¤ã®å(long, double, string, date)ã ãã§ãªããä»»æã®åãã¸ã§ããã©ã¡ã¼ã¿ã¨ãã¦ä½¿ç¨ã§ããããã«ãªãã¾ããï¼
(çç¥)
ãã®æ¹è¨ã«ãããJobParameter ã¯ä»»æã®åã«ãããã¨ãã§ããããã«ãªãã¾ããããã®å¤æ´ã«ãããgetType() ã®æ»ãå¤ã®åã®å¤æ´ããParameterType åæåã®åé¤ãªã©ãå¤ãã® API ã®å¤æ´ãå¿ è¦ã«ãªãã¾ããããã®æ´æ°ã«é¢é£ãããã¹ã¦ã®å¤æ´ã¯ã"[Deprecated|Moved|Removed] APIs" ã»ã¯ã·ã§ã³ã«ããã¾ãã
Â
ãã®å¤æ´ã¯ãã¸ã§ããã©ã¡ã¼ã¿ããã¼ã¿ãã¼ã¹ã«æ°¸ç¶åãããæ¹æ³ã«å½±é¿ãåã¼ãã¾ãã (å®ç¾©æ¸ã¿ã®åãã¨ã«4ã¤ã®ç°ãªãã«ã©ã ããªããªãã¾ãã)ãDDLã®å¤æ´ã«ã¤ãã¦ã¯ãBATCH_JOB_EXECUTION_PARAMSã®åã®å¤æ´ã確èªãã¦ãã ããããã©ã¡ã¼ã¿ã®åã®å®å ¨ä¿®é£¾åãããã©ã¡ã¼ã¿å¤ã¨åæ§ã«Stringã¨ãã¦æ°¸ç¶åãããããã«ãªãã¾ãããæååãªãã©ã«ã¯ãSpringã®æ¨æºå¤æãµã¼ãã¹ã§ãã©ã¡ã¼ã¿åã«å¤æããã¾ããæ¨æºã®å¤æãµã¼ãã¹ã¯ãã¦ã¼ã¶ã¼åºæã®åãStringãªãã©ã«ã«å¤æããããStringãªãã©ã«ããå¤æãããããããã«å¿ è¦ãªã³ã³ãã¼ã¿ã§å¼·åãããã¨ãã§ãã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
ã»ã¸ã§ããã©ã¡ã¼ã¿ã¼ã®åã®ç¸ãããªãã£ãã®ã§ãèªç±ã«ãªã£ãã¨ããããããBATCH_JOB_EXECUTION_PARAMSã«å½±é¿ãä¸ãã¦ãã¦ãåã§ãªãªã¸ããªãã£ãåºãã¨ãå¤æã³ã³ãã¼ã¿ã¼ãå¿ è¦ã«ãªãã
Â
Default job parameter conversion
The default notation of job parameters in v4 was specified as follows:
[+|-]parameterName(parameterType)=value
ÂwhereÂ
parameterType
 is one of [string,long,double,date]. In addition to be limited and constraining, this notation caused several issues as described in https://github.com/spring-projects/spring-batch/issues/3960.In v5, there are two way to specify job parameters:
Default notation
The default notation is specified as follows:
parameterName=parameterValue,parameterType,identificationFlag
ÂwhereÂ
parameterType
 is the fully qualified name of the type of the parameter. Spring Batch provides theÂDefaultJobParametersConverter
 to support this notation.Extended notation
While the default notation is well suited for the majority of use cases, it might be inconvenient when the value contains a comma for example. In this case, the extended notation can be used, which is inspired by Spring Boot's Json Application Properties and specified as follows:
parameterName='{"value": "parameterValue", "type":"parameterType", "identifying": "booleanValue"}'
ÂwhereÂ
parameterType
 is the fully qualified name of the type of the parameter. Spring Batch provides theÂJsonJobParametersConverter
 to support this notation.
ï¼å訳ï¼
ã¸ã§ããã©ã¡ã¼ã¿ã®ããã©ã«ãå¤æ
v4ã«ãããã¸ã§ãã»ãã©ã¡ã¼ã¿ã®ããã©ã«ã表è¨ã¯ä»¥ä¸ã®ããã«è¦å®ããã¦ããï¼
[parameterName(parameterType)=value
ããã§ãparameterTypeã¯[string,long,double,date]ã®ããããã§ããéå®çã§å¶ç´ã®å¤ããã®è¡¨è¨æ³ã¯ãhttps://github.com/spring-projects/spring-batch/issues/3960 ã§èª¬æããã¦ããããã«ãããã¤ãã®åé¡ãå¼ãèµ·ããã¦ãã¾ããã
v5ã§ã¯ãã¸ã§ããã©ã¡ã¼ã¿ãæå®ãã2ã¤ã®æ¹æ³ãããã¾ãï¼
Â
ããã©ã«ã表è¨æ³
ããã©ã«ãã®è¡¨è¨æ¹æ³ã¯ä»¥ä¸ã®éãã§ãï¼
parameterName=parameterValue,parameterType,identificationFlag
ããã§ãparameterTypeã¯ãã©ã¡ã¼ã¿ã®åã®å®å
¨ä¿®é£¾åã§ããSpring Batchã¯ãã®è¡¨è¨æ³ããµãã¼ãããDefaultJobParametersConverterãæä¾ãã¾ãã
Â
æ¡å¼µè¡¨è¨æ³
Â
ããã©ã«ãã®è¨æ³ã¯å¤§åã®ã¦ã¼ã¹ã±ã¼ã¹ã«é©ãã¦ãã¾ãããä¾ãã°å¤ã«ã«ã³ããå«ã¾ãã¦ããå ´åã¯ä¸ä¾¿ããããã¾ããããã®å ´åãSpring Bootã®Json Application Propertiesã«ãã³ããå¾ãæ¡å¼µè¨æ³ã使ããã¨ãã§ãã次ã®ããã«æå®ãã¾ãï¼
parameterName='{"value"ï¼parameterName='{"value": "parameterValue", "type": "parameterType", "identifying"ï¼"booleanValue"}'
ããã§ãparameterTypeã¯ãã©ã¡ã¼ã¿ã®åã®å®å
¨ä¿®é£¾åã§ããSpring Batchã¯ãã®è¨æ³ããµãã¼ãããJsonJobParametersConverterãæä¾ãã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
ã»ããã¯ã¸ã§ããèµ·åããéã«ãã¢ããªã±ã¼ã·ã§ã³ã«å¼ã渡ããã©ã¡ã¼ã¿ã¼ã®ã話ã
SpringBootãèµ·åããéã«å¼ã渡ããã©ã¡ã¼ã¿ã¼ã®åã説æãã¦ããã
ããªãè¤éãªãã®ã対å¿ã§ããããã«è¦ããã
Â
Historical data access implications
Due to this breaking change about handling job parameters, some APIs that are designed to explore batch meta-data should not be used for job instances that were launched with v4. For example:
JobExplorer#getJobInstances
 could retrieve a mix of historical data between v4 and v5 and might fails at loading job parameters of v4 (#4352). In this particular case, make sure to start at the index of the first instance executed with v5.JobExplorer#getJobExecution
 could fail at retrieving job parameters if the passed job execution ID is one of an execution that was run with v4.Another case where this change has implications on loading job parameters is when restarting failed job instances. It is expected that all failed v4 job instances are either restarted to success or abandoned before the migration to v5 is done.
ï¼å訳ï¼
å±¥æ´ãã¼ã¿ã¢ã¯ã»ã¹ã¸ã®å½±é¿
ã¸ã§ããã©ã¡ã¼ã¿ã®åãæ±ãã«é¢ãããã®å¤æ´ã«ããããããã¡ã¿ãã¼ã¿ãæ¢ç´¢ããããã«è¨è¨ãããããã¤ãã®APIã¯ãv4ã§èµ·åãããã¸ã§ãã¤ã³ã¹ã¿ã³ã¹ã«ã¯ä½¿ç¨ã§ãã¾ããã ãã¨ãã°ã以ä¸ã®ãããªãã®ã§ãï¼
JobExplorer#getJobInstancesã¯v4ã¨v5ã®å±¥æ´ãã¼ã¿ãæ··å¨ãã¦åå¾ããå¯è½æ§ããããv4ã®ã¸ã§ããã©ã¡ã¼ã¿ã®èªã¿è¾¼ã¿ã«å¤±æããå¯è½æ§ãããã¾ã(#4352)ããã®ãããªå ´åã¯ãv5ã§æåã«å®è¡ãããã¤ã³ã¹ã¿ã³ã¹ã®ã¤ã³ããã¯ã¹ããéå§ããããã«ãã¦ãã ããã
渡ãããã¸ã§ãå®è¡IDãv4ã§å®è¡ããããã®ã§ããå ´åãJobExplorer#getJobExecutionã¯ã¸ã§ããã©ã¡ã¼ã¿ã®åå¾ã«å¤±æããå¯è½æ§ãããã¾ãã
ãã®å¤æ´ãã¸ã§ããã©ã¡ã¼ã¿ã®ãã¼ãã«å½±é¿ãããã1ã¤ã®ã±ã¼ã¹ã¯ã失æããã¸ã§ãã¤ã³ã¹ã¿ã³ã¹ãåèµ·åããå ´åã§ããv5ã¸ã®ç§»è¡ãå®äºããåã«ããã¹ã¦ã®å¤±æããv4ã¸ã§ãã¤ã³ã¹ã¿ã³ã¹ãæåããããã«åèµ·åãããããæ¾æ£ããããã¨ãæå¾
ããã¾ãã
Â
ï¼ã³ã¡ã³ãï¼
ã»v4ã®ã¸ã§ããã©ã¡ã¼ã¿ã¼ã§èµ·åãããã¼ã¿ãæ®ã£ã¦ããã¨ãv5ã§å¤±æããå¯è½æ§ãããã¨â¦
çµæ§ãªè² ã®éºç£ãªã®ã¨ãç°å¢ã«ãã£ã¦ã¯ãããããèµ·åããªãã¿ãããªãã¨ãçºçããããªã®ã§ãè¦æ³¨æã
Â
Â
Deprecated APIs
ï¼å訳ï¼
ã»éæ¨å¥¨API
Â
ï¼ã³ã¡ã³ãï¼
ã»ãã®ãã¡æ¶ããã®ã§ã使ã£ã¦ãããè¦æ³¨æã
Â
The following APIs have been deprecated in version 5.0:
org.springframework.batch.core.listener.ChunkListenerSupport
org.springframework.batch.core.listener.StepExecutionListenerSupport
org.springframework.batch.repeat.listener.RepeatListenerSupport
org.springframework.batch.core.listener.JobExecutionListenerSupport
org.springframework.batch.core.listener.SkipListenerSupport
org.springframework.batch.item.data.Neo4jItemReader
org.springframework.batch.item.data.builder.Neo4jItemWriterBuilder
org.springframework.batch.item.data.Neo4jItemWriter
org.springframework.batch.item.data.builder.Neo4jItemWriterBuilder
org.springframework.batch.item.database.support.SqlPagingQueryUtils#generateLimitGroupedSqlQuery(org.springframework.batch.item.database.support.AbstractSqlPagingQueryProvider, boolean, java.lang.String)
org.springframework.batch.core.repository.dao.JdbcJobInstanceDao#setJobIncrementer(DataFieldMaxValueIncrementer jobIncrementer)
org.springframework.batch.core.launch.support.SimpleJobLauncher
org.springframework.batch.core.configuration.annotation.JobBuilderFactory
org.springframework.batch.core.configuration.annotation.StepBuilderFactory
- The constructorÂ
org.springframework.batch.core.job.builder.JobBuilder#JobBuilder(java.lang.String)
- The constructorÂ
org.springframework.batch.core.step.builder.StepBuilder#StepBuilder(java.lang.String)
- The methodÂ
org.springframework.batch.core.step.builder.StepBuilder#tasklet(org.springframework.batch.core.step.tasklet.Tasklet)
- The methodÂ
org.springframework.batch.core.step.builder.StepBuilder#chunk(int)
- The methodÂ
org.springframework.batch.core.step.builder.StepBuilder#chunk(org.springframework.batch.repeat.CompletionPolicy)
- The methodÂ
org.springframework.batch.core.step.builder.TaskletStepBuilder#tasklet(org.springframework.batch.core.step.tasklet.Tasklet)
- The constructorÂ
org.springframework.batch.integration.chunk.RemoteChunkingManagerStepBuilder#RemoteChunkingManagerStepBuilder(java.lang.String)
- The constructorÂ
org.springframework.batch.integration.partition.RemotePartitioningManagerStepBuilder#RemotePartitioningManagerStepBuilder(java.lang.String)
- The constructorÂ
org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilder#RemotePartitioningWorkerStepBuilder(java.lang.String)
- The methodÂ
org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilder#tasklet(org.springframework.batch.core.step.tasklet.Tasklet)
- The methodÂ
org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilder#chunk(int)
- The methodÂ
org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilder#chunk(org.springframework.batch.repeat.CompletionPolicy)
- The methodÂ
org.springframework.batch.core.JobParameters#toProperties
- The methodÂ
org.springframework.batch.core.JobParametersBuilder#addParameter
- The classÂ
org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner
- The classÂ
org.springframework.batch.test.DataSourceInitializer
- The classÂ
org.springframework.batch.integration.step.DelegateStep
- The annotationÂ
org.springframework.batch.support.annotation.Classifier
- The classÂ
org.springframework.batch.item.ItemStreamSupport
- The methodÂ
org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder#throttleLimit
- The methodÂ
org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate#setThrottleLimit
- The interfaceÂ
org.springframework.batch.repeat.support.ResultHolder
- The interfaceÂ
org.springframework.batch.repeat.support.ResultQueue
- The classÂ
org.springframework.batch.repeat.support.ResultHolderResultQueue
- The classÂ
org.springframework.batch.repeat.support.ThrottleLimitResultQueue
Please refer to the Javadoc of each API for more details about the suggested replacement.
ï¼å訳ï¼
æ¨å¥¨ãããç½®ãæãã®è©³ç´°ã«ã¤ãã¦ã¯ãåAPIã®Javadocãåç §ã®ãã¨ã
Â
ï¼ã³ã¡ã³ãï¼
ã»Javadocè¦ã¾ãããã
Â
Moved APIs
ï¼å訳ï¼
ã»ç§»åããAPI
Â
ï¼ã³ã¡ã³ãï¼
ã»ä½¿ã£ã¦ããããimportæã®ããã±ã¼ã¸ã®å¤æ´ãå¿ è¦ã¨ãªãããã
Â
- TheÂ
BatchMetrics
 class (which is intended for internal use only) has been moved fromÂorg.springframework.batch.core.metrics
 to theÂorg.springframework.batch.core.observability
 package.- TheÂ
Chunk
 class was moved from theÂorg.springframework.batch.core.step.item
 package (spring-batch-core
 module) to theÂorg.springframework.batch.item
 package (spring-batch-infrastrucutre
 module)- TheÂ
ScopeConfiguration
 class has moved fromÂorg.springframework.batch.core.configuration.annotation
 toÂorg.springframework.batch.core.configuration.support
Â
Removed APIs
ï¼å訳ï¼
åé¤ãããAPI
Â
ï¼ã³ã¡ã³ãï¼
ã»ãã¼ã¸ã§ã³ã¢ããããã¨ã使ãã¾ããã
Â
- ClassÂ
org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean
- ClassÂ
org.springframework.batch.core.repository.dao.MapExecutionContextDao
- ClassÂ
org.springframework.batch.core.repository.dao.MapJobExecutionDao
- ClassÂ
org.springframework.batch.core.repository.dao.MapJobInstanceDao
- ClassÂ
org.springframework.batch.core.repository.dao.MapStepExecutionDao
- ClassÂ
org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean
- ClassÂ
org.springframework.batch.core.repository.dao.XStreamExecutionContextStringSerializer
- ClassÂ
org.springframework.batch.core.configuration.support.ClassPathXmlJobRegistry
- ClassÂ
org.springframework.batch.core.configuration.support.ClassPathXmlApplicationContextFactory
- ClassÂ
org.springframework.batch.core.launch.support.ScheduledJobParametersFactory
- ClassÂ
org.springframework.batch.item.data.AbstractNeo4jItemReader
- ClassÂ
org.springframework.batch.item.database.support.ListPreparedStatementSetter
- ClassÂ
org.springframework.batch.integration.chunk.RemoteChunkingMasterStepBuilder
- ClassÂ
org.springframework.batch.integration.chunk.RemoteChunkingMasterStepBuilderFactory
- ClassÂ
org.springframework.batch.integration.partition.RemotePartitioningMasterStepBuilder
- ClassÂ
org.springframework.batch.integration.partition.RemotePartitioningMasterStepBuilderFactory
- ClassÂ
org.springframework.batch.test.AbstractJobTests
- ClassÂ
org.springframework.batch.item.xml.StaxUtils
Â
ï¼ã³ã¡ã³ãï¼
ã»ä»£æ¿æ段ããªããã®ãããã®ããè¦æ³¨æã
Â
- EnumÂ
org.springframework.batch.item.file.transform.Alignment
- EnumÂ
org.springframework.batch.core.JobParameter#ParameterType
ï¼ã³ã¡ã³ãï¼
ã»ä½¿ãå¿ è¦ããªããªã£ãEnumãå¤åãå»æ¢ãããClassé¢é£ã®ãã®ã
Â
- MethodÂ
org.springframework.batch.core.JobExecution#stop()
- MethodÂ
org.springframework.batch.core.JobParameters#getDouble(String key, double defaultValue)
- MethodÂ
org.springframework.batch.core.JobParameters#getLong(String key, long defaultValue)
- MethodÂ
org.springframework.batch.core.partition.support.SimpleStepExecutionSplitter(JobRepository jobRepository, Step step, Partitioner partitioner)
- MethodÂ
org.springframework.batch.core.partition.support.SimpleStepExecutionSplitter#getStartable(StepExecution stepExecution, ExecutionContext context)
- MethodÂ
org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean#getJobRepository()
- MethodÂ
org.springframework.batch.item.database.AbstractCursorItemReader#cleanupOnClose()
- MethodÂ
org.springframework.batch.item.database.HibernateItemWriter#doWrite(HibernateOperations hibernateTemplate, List<? extends T> items)
- MethodÂ
org.springframework.batch.item.database.JdbcCursorItemReader#cleanupOnClose()
- MethodÂ
org.springframework.batch.item.database.StoredProcedureItemReader#cleanupOnClose()
- MethodÂ
org.springframework.batch.item.database.builder.HibernatePagingItemReaderBuilder#useSatelessSession(boolean useStatelessSession)
- MethodÂ
org.springframework.batch.item.file.MultiResourceItemReader#getCurrentResource()
- MethodÂ
org.springframework.batch.integration.config.annotation.BatchIntegrationConfiguration#remoteChunkingMasterStepBuilderFactory()
- MethodÂ
org.springframework.batch.integration.config.annotation.BatchIntegrationConfiguration#remotePartitioningMasterStepBuilderFactory()
- MethodÂ
org.springframework.batch.item.util.FileUtils#setUpOutputFile(File file, boolean restarted, boolean overwriteOutputFile)
ï¼ã³ã¡ã³ãï¼
ã»ã¡ã½ããã¯å¼æ°ãå¤ãã£ã¦ããçããããã®ã§ãåãã¡ã½ããåã§ç¢ºèªããã
Â
Moreover, the following APIs have been removed/updated without deprecation:
- The interfaceÂ
org.springframework.batch.core.configuration.annotation.BatchConfigurer
 was removed. See https://github.com/spring-projects/spring-batch/issues/3942- The classÂ
org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer
 was removed. See https://github.com/spring-projects/spring-batch/issues/3942- The methodÂ
org.springframework.batch.core.step.builder.SimpleStepBuilder#processor(Function)
 has been removed to allow lambdas to be passed as item processors. See https://github.com/spring-projects/spring-batch/issues/4061 for more details about the rationale behind this removal. If you use an actualÂFunction
 as argument forÂSimpleStepBuilder::processor
, then you can change that toÂ.processor(function::apply)
 to migrate to v5.org.springframework.batch.item.file.builder.FlatFileItemWriterBuilder#resource
,Âorg.springframework.batch.item.file.ResourceAwareItemWriterItemStream#setResource
,Âorg.springframework.batch.item.json.builder.JsonFileItemWriterBuilder#resource
,Âorg.springframework.batch.item.json.JsonFileItemWriter#JsonFileItemWriter
,Âorg.springframework.batch.item.support.AbstractFileItemWriter#setResource
,Âorg.springframework.batch.item.xml.builder.StaxEventItemWriterBuilder#resource
 andÂorg.springframework.batch.item.xml.StaxEventItemWriter#setResource
 have been updated to accept aÂorg.springframework.core.io.WritableResource
 instead of aÂorg.springframework.core.io.Resource
. For more details about this change, please check https://github.com/spring-projects/spring-batch/issues/756- The static typeÂ
org.springframework.batch.item.data.builder.RepositoryItemReaderBuilder.RepositoryMethodReference
 along with the methodÂorg.springframework.batch.item.data.builder.RepositoryItemReaderBuilder#repository(RepositoryMethodReference<?>)
 have been removed.- The signature of the methodÂ
ItemWriter#write(List)
 was changed toÂItemWriter#write(Chunk)
- All implementations ofÂ
ItemWriter
 were updated to use theÂChunk
 API instead ofÂList
- All methods in theÂ
ItemWriteListener
 interface were updated to use theÂChunk
 API instead ofÂList
- All implementations ofÂ
ItemWriteListener
 were updated to use theÂChunk
 API instead ofÂList
- The constructor ofÂ
ChunkRequest
 was changed to accept aÂChunk
 instead of aÂCollection
 of items- The return type ofÂ
ChunkRequest#getItems()
 was changed fromÂList
 toÂChunk
- TheÂ
JobRepositoryTestUtils
 was changed to work against theÂJobRepository
 interface without depending on a datasource bean. For this change, the constructor that takes aÂDataSource
 as a parameter (JobRepositoryTestUtils(JobRepository jobRepository, DataSource dataSource)
) as well as the publicÂDataSource
 setter were removed. This is related to issue #4070.- The methodÂ
StepBuilderHelper#transactionManager(PlatformTransactionManager)
 was moved toÂAbstractTaskletStepBuilder
. This is related to issue https://github.com/spring-projects/spring-batch/issues/4130.- The methodsÂ
RemotePartitioningManagerStepBuilder#transactionManager(PlatformTransactionManager)
 andÂRemotePartitioningWorkerStepBuilder#transactionManager(PlatformTransactionManager)
 were removed. A transaction manager is not required for those type of steps. This is related to issue https://github.com/spring-projects/spring-batch/issues/4130.- The methodÂ
JobParameter#getType
 now returnsÂT
 instead ofÂObject
- The constructors inÂ
JobParameter
 that took the 4 pre-defined job parameter types (date, string, long, double) where removed.- The constructorÂ
SkipWrapper(Throwable e)
 was removed- The setterÂ
setIsolationLevelForCreate(Isolation)
 inÂAbstractJobRepositoryFactoryBean
 was renamed toÂsetIsolationLevelForCreateEnum
- The return type ofÂ
JobExplorer#getJobInstanceCount
 andÂJobInstanceDao#getJobInstanceCount
 has been changed fromÂint
 toÂlong
- The return type ofÂ
JobRepository#getStepExecutionCount
 andÂStepExecutionDao#countStepExecutions
 has been changed fromÂint
 toÂlong
ï¼å訳ï¼
ããã«ã以ä¸ã®APIãå»æ¢ããããã¨ãªãåé¤/æ´æ°ãããï¼
org.springframework.batch.core.configuration.annotation.BatchConfigurer ã¤ã³ã¿ã¼ãã§ã¼ã¹ãåé¤ããã¾ãããhttps://github.com/spring-projects/spring-batch/issues/3942 ãåç
§ãã¦ãã ããã
org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer ã¯ã©ã¹ãåé¤ããã¾ãããhttps://github.com/spring-projects/spring-batch/issues/3942 ãåç
§ã
org.springframework.batch.core.step.builder.SimpleStepBuilder#processor(Function) ã¡ã½ãããåé¤ãããé
ç®ããã»ããµã¨ãã¦ã©ã ãã渡ããããã«ãªã£ãããã®åé¤ã®æ ¹æ ã«ã¤ãã¦ã¯ https://github.com/spring-projects/spring-batch/issues/4061 ãåç
§ãã¦ãã ãããSimpleStepBuilder::processorã®å¼æ°ã¨ãã¦å®éã®Functionã使ç¨ãã¦ããå ´åãv5ã«ç§»è¡ããããã«.processor(function::apply)ã«å¤æ´ãããã¨ãã§ãã¾ãã
org.springframework.batch.item.data.builder.RepositoryItemReaderBuilder.RepositoryMethodReference ã¨ããéçå㨠org.springframework.batch.item.data.builder.RepositoryItemReaderBuilder#repository(RepositoryMethodReference<? >) ã¨ããã¡ã½ãããåé¤ããã¾ããã
ItemWriter#write(List)ã¡ã½ããã®ã·ã°ããã£ãItemWriter#write(Chunk)ã«å¤æ´ãããã
ItemWriterã®ãã¹ã¦ã®å®è£
ããListã®ä»£ããã«Chunk APIã使ç¨ããããã«æ´æ°ããã¾ããã
ItemWriteListenerã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ãã¹ã¦ã®ã¡ã½ããããListã®ä»£ããã«Chunk APIã使ç¨ããããã«æ´æ°ããã¾ããã
ItemWriteListener ã®ãã¹ã¦ã®å®è£
ããList ã®ä»£ããã« Chunk API ã使ç¨ããããã«æ´æ°ããã¾ããã
ChunkRequest ã®ã³ã³ã¹ãã©ã¯ã¿ã¯ãã¢ã¤ãã ã® Collection ã®ä»£ããã« Chunk ãåãå
¥ããããã«å¤æ´ããã¾ããã
ChunkRequest#getItems() ã®æ»ãå¤ã®åã List ãã Chunk ã«å¤æ´ããã¾ããã
JobRepositoryTestUtils ã¯ããã¼ã¿ã½ã¼ã¹ãã¼ã³ã«ä¾åããã« JobRepository ã¤ã³ã¿ã¼ãã§ã¼ã¹ã«å¯¾ãã¦åä½ããããã«å¤æ´ããã¾ããããã®å¤æ´ã«ä¼´ãããã¼ã¿ã½ã¼ã¹ããã©ã¡ã¼ã¿ã¨ãã¦åãåãã³ã³ã¹ãã©ã¯ã¿ï¼JobRepositoryTestUtils(JobRepository jobRepository, DataSource dataSource)ï¼ã¨ãããªãã¯ãã¼ã¿ã½ã¼ã¹ã»ãã¿ãåé¤ããã¾ããããã㯠issue #4070 ã«é¢é£ãã¦ãã¾ãã
StepBuilderHelper#transactionManager(PlatformTransactionManager) 㯠AbstractTaskletStepBuilder ã«ç§»åããã¾ãããããã¯åé¡ https://github.com/spring-projects/spring-batch/issues/4130 ã«é¢é£ãã¦ãã¾ãã
RemotePartitioningManagerStepBuilder#transactionManager(PlatformTransactionManager) ããã³ RemotePartitioningWorkerStepBuilder#transactionManager(PlatformTransactionManager) ã¡ã½ããã¯åé¤ããã¾ããããããã®ã¿ã¤ãã®ã¹ãããã§ã¯ããã©ã³ã¶ã¯ã·ã§ã³ããã¼ã¸ã£ã¯å¿
è¦ããã¾ãããããã¯åé¡ https://github.com/spring-projects/spring-batch/issues/4130 ã«é¢é£ãã¦ãã¾ãã
JobParameter#getType ã¡ã½ãã㯠Object ã§ã¯ãªã T ãè¿ãããã«ãªãã¾ããã
JobParameterã®ã³ã³ã¹ãã©ã¯ã¿ã§ãäºåã«å®ç¾©ããã4ã¤ã®ã¸ã§ããã©ã¡ã¼ã¿åï¼dateãstringãlongãdoubleï¼ãåé¤ããã¾ããã
ã³ã³ã¹ãã©ã¯ã¿SkipWrapper(Throwable e)ãåé¤ããã¾ããã
AbstractJobRepositoryFactoryBean ã®ã»ãã¿ã¼ setIsolationLevelForCreate(Isolation) 㯠setIsolationLevelForCreateEnum ã«ååãå¤æ´ããã¾ããã
JobExplorer#getJobInstanceCountã¨JobInstanceDao#getJobInstanceCountã®æ»ãå¤ã®åãintããlongã«å¤æ´ããã¾ããã
JobRepository#getStepExecutionCountããã³StepExecutionDao#countStepExecutionsã®æ»ãå¤ã®åãintããlongã«å¤æ´ããã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»é¢é£ããã¯ã©ã¹ãã¡ã½ãããgrepãã¦ã該å½ããããåçç±ã確èªããã®ãããããã
Â
Pruning
ï¼å訳ï¼
åªå®
Â
ï¼ã³ã¡ã³ãï¼
ã»ãµãã¼ãçµäºç³»
Â
SQLFire support removal
SqlFire has been announced to be EOL as of November 1st, 2014. The support of SQLFire as a job repository was deprecated in version 4.3 and removed in version 5.0.
ï¼å訳ï¼
SQLFireãµãã¼ãçµäºã®ãç¥ãã
SqlFireã¯2014å¹´11æ1æ¥ããã£ã¦EOLã¨ãªããã¨ãçºè¡¨ããã¾ãããSQLFireã®ã¸ã§ããªãã¸ããªã¨ãã¦ã®ãµãã¼ãã¯ãã¼ã¸ã§ã³4.3ã§å»æ¢ããããã¼ã¸ã§ã³5.0ã§åé¤ããã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»åé¤ããã¦ããã®ã§ã使ããªãã
Â
JSR-352 implementation removal
Due to a lack of adoption, the implementation of the JSR-352 has been discontinued in this release.
ï¼å訳ï¼
JSR-352å®è£ ã®åé¤
JSR-352 ã®å®è£ ã¯ãæ¡ç¨ãããªãã£ãããããã®ãªãªã¼ã¹ã§å»æ¢ããã¾ããã
Â
ï¼ã³ã¡ã³ãï¼
ã»é¢é£ããå®è£ ããã¦ããå ´åã¯ãSpringBatchã使ããªãï¼
Â
Gemfire support removal
Based on the decision to discontinue the support of Spring Data for Apache Geode, the support for Geode in Spring Batch was removed. The code was moved to the spring-batch-extensions repository as a community-driven effort.
ï¼å訳ï¼
Gemfireãµãã¼ãã®å»æ¢
Spring Data for Apache Geodeã®ãµãã¼ãä¸æ¢ã®æ±ºå®ã«åºã¥ããSpring Batchã«ãããGeodeã®ãµãã¼ããåé¤ããããã³ãã¥ããã£ä¸»å°ã®åãçµã¿ã¨ãã¦ãã³ã¼ãã¯spring-batch-extensionsãªãã¸ããªã«ç§»åãããã
Â
ï¼ã³ã¡ã³ãï¼
ã»ã¦ã¼ã¶ã¼ã®ã»ãã·ã§ã³ç®¡çã«ä½¿ãããã©ã¤ãã©ãªã®æ§åããªãã¸ããªãå¤ããã®ã§ãå¥é追å ãå¿ è¦ã«ãªãï¼
Â
æå¾ã«
æå¤ã¨æ ¹æ¬çãªèãæ¹ã®å¤æ´ãããã®ã§ãç¹ã«ã¤ã¬ã®ã¥ã©ã¼ãªãã¨ããã£ã¦ããå ´åãä»ã¾ã§ã§ãããã¨ããã®ã¾ã¾ã®å½¢ã§ã§ããã¨æããªãã»ããããããã
Â