| Title | 스프링 부트 4.0.1 에서 스프링 배치의 라이브러리가 변경되었다. The Spring Batch library has been updated in Spring Boot 4.0.1. | ||||||
| Writer | Ji-Seob Lee | Write Date | Jan 8 2026 | Modify Date | Jan 9 2026 | View Count | 24 |
In Spring Boot 4.0.1, the Spring Batch library has been updated.
In Spring Boot 4.0.1, the Spring Batch library version has been updated as follows:
org\springframework\batch\spring-batch-core\6.0.1\spring-batch-core-6.0.1.jar
org\springframework\batch\spring-batch-infrastructure\6.0.1\spring-batch-infrastructure-6.0.1.jar
The Java compiler support version for these two files is 17 or higher.
Reviewing the main classes, the changes are as follows:
The approach to implementing batch processing has also changed.
Not all changes are listed here;
only some key classes are documented.
[ spring-batch-core-6.0.1.jar ] 3.x.x : org.springframework.batch.core.Job 4.0.1 : org.springframework.batch.core.job.Job 3.x.x : org.springframework.batch.core.Step 4.0.1 : org.springframework.batch.core.step.Step 3.x.x : org.springframework.batch.core.JobParametersInvalidException 4.0.1 : org.springframework.batch.core.job.parameters.InvalidJobParametersException 3.x.x : org.springframework.batch.core.JobParametersBuilder 4.0.1 : org.springframework.batch.core.job.parameters.JobParametersBuilder 3.x.x : org.springframework.batch.core.repository.JobExecutionAlreadyRunningException 4.0.1 : org.springframework.batch.core.launch.JobExecutionAlreadyRunningException 3.x.x : org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException 4.0.1 : org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException 3.x.x : org.springframework.batch.core.repository.JobRestartException 4.0.1 : org.springframework.batch.core.launch.JobRestartException [ spring-batch-infrastructure-6.0.1.jar ] 3.x.x : org.springframework.batch.repeat.RepeatStatus 4.0.1 : org.springframework.batch.infrastructure.repeat.RepeatStatus Upgrading only the Spring Batch version to 4.0.1 causes an error
because the batch class information has changed as shown above.
In Spring Boot 4.0.1, the JobLauncher is deprecated.
The method for using JobLauncher.run() is as follows.
In Spring Boot 4.0.1, the JobLauncher itself is still available,
but it is highly likely that the previously commonly used implementations or specific integration methods have changed.
It is strongly recommended to use a more abstracted interface rather than directly using JobLauncher.
1. Use JobOperator (Recommended)
In recent Spring Batch versions, using JobOperator instead of JobLauncher to start or stop jobs is recommended.
JobOperator is more flexible as it can execute jobs by passing the job name and parameters as strings.
@Autowired
private JobOperator jobOperator;
public void runJob() throws Exception {
// Execute with jobName and jobParameters (string format) as arguments
Long executionId = jobOperator.start("myJobName", "parameter1=value1,time=" + System.currentTimeMillis());
}
In Spring Boot + MyBatis projects, you may encounter an issue where @Mapper classes fail to register as beans.
This can be resolved by updating the org.mybatis.spring.boot.mybatis-spring-boot-starter dependency to version 4.0.1.
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>4.0.1</version>
</dependency>
For reference, add the @EnableScheduling annotation to the Application Class to use the @Scheduled annotation.
package spring_boot_batch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication
public class SpringBootBatchApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootBatchApplication.class, args);
}
}
A batch program for Spring Boot 4.0.1 has been attached to this post as a file.
You may find it useful for reference.
[ References cited ]
- Google AI
| |||||||
| Attachment File | BatchConfig.java (3,008 byte) BatchScheduler.java (1,575 byte) pom.xml (2,746 byte) SpringBootBatchApplication.java (413 byte) application.properties (42 byte) | ||||||