Application does not terminate upon completion of CommandLineRunner anymore
See original GitHub issueI run some java batch processes using this code structure:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public CommandLineRunner commandLineRunner(MyServiceInstance service) {
return args -> {
service.doJob();
};
}
}
Prior spring 2.4.2 my service/process terminates after doing it’s Job, so the code was convenient to run batch jobs. Starting from spring 2.4.2 the service instances do not terminate. So image the result all my instances are running in my AWS Batch account causing cost increases and blocking other jobs.
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (12 by maintainers)
Top Results From Across the Web
spring boot application does not exit after all tasks are ...
First off, you are not closing the ExecutorService properly, your multiThreadTest should look like: public void multiThreadTest() throws ...
Read more >Spring Boot Reference Guide
Try the How-to documents. They provide solutions to the most common questions. Learn the Spring basics. Spring Boot builds on many other Spring...
Read more >Spring Command Line application doesn't terminate
The issue is that after Neo4j connectivity addition, the application no longer exits after its main() method finishes.
Read more >Activiti User Guide
The Activiti UI application uses an in-memory H2 database by default, ... Depending on the type or event, these entities cannot be updated...
Read more >IntelliJ does not terminate Spring Boot applications
I am using IntelliJ IDEA 2017.2.5 Ultimate on macOs 10.12.6. I have build very simple Java 1.8 command line application using Spring Boot...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@eduardobarrena-tc You can already use Spring Boot without auto-configuration, if you look at
@SpringBootApplication
you’ll see it’s actually:If you don’t want auto-configuration you can annotate your main class with:
You can also exclude the
spring-boot-autoconfigure
jar if you want to be totally sure that no auto-configuration functionality is used.We’re in a bit of a catch 22. The
shutdown()
method does get called, but only when theApplicationContext
is closed. That won’t happen if non-daemon threads are still active.@eduardobarrena-tc you can change your main method to this to force the context to close: