-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
for: external-projectIssues that should be opened against other Spring projectsIssues that should be opened against other Spring projectsstatus: invalidLegacy label from JIRA. Superseded by "status: declined"Legacy label from JIRA. Superseded by "status: declined"type: bug
Description
Bug description
I notice that a spring boot batch application does not shut down automatically after completing a job when using Spring data JPA. The job completes successfully but the spring boot application remains running and has to be stopped manually (e.g. by pressing Ctrl + C
).
Environment
Spring boot version: 2.3.0.RELEASE
Java version: 1.8
OS: Windows
Steps to reproduce
- Create a new spring boot project from https://start.spring.io/
- Add the following dependencies:
spring-boot-starter-batch
spring-boot-starter-data-jpa
h2
- Create a tasklet step
- Configure a spring batch job referencing the tasklet step
Expected behavior
The job should execute successfully, and shut down automatically.
Minimal Complete Reproducible example
Dependencies in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
Batch configuration class
@Configuration
public class BatchConfiguration {
@Bean
public Job sampleJob(JobBuilderFactory jobBuilderFactory, Step step1) {
return jobBuilderFactory.get("sampleJob").incrementer(new RunIdIncrementer()).flow(step1).end().build();
}
@Bean
public Step step1(StepBuilderFactory stepBuilderFactory, StepTasklet tasklet) {
return stepBuilderFactory.get("step1").tasklet(tasklet).build();
}
}
Tasklet step class
public class StepTasklet implements Tasklet {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
System.out.println("Executing tasklet step...");
return RepeatStatus.FINISHED;
}
}
Metadata
Metadata
Assignees
Labels
for: external-projectIssues that should be opened against other Spring projectsIssues that should be opened against other Spring projectsstatus: invalidLegacy label from JIRA. Superseded by "status: declined"Legacy label from JIRA. Superseded by "status: declined"type: bug