Run Spring Not as Server

Under the directory /scr/main/resources/application.properties, add the following line:

spring.main.web-application-type=NONE 

In that case, Spring will run as application, and end once it task is completed. You might want to implements CommandLineRunner in your main application class in that case.