{"id":60055,"date":"2022-11-04T14:11:00","date_gmt":"2022-11-04T14:11:00","guid":{"rendered":"https:\/\/foojay.io\/?p=60055"},"modified":"2023-08-28T12:48:39","modified_gmt":"2023-08-28T12:48:39","slug":"clean-shutdown-of-spring-boot-applications","status":"publish","type":"post","link":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/","title":{"rendered":"Clean Shutdown of Spring Boot Applications"},"content":{"rendered":"\n<p>For the last three to four years, I have been working on Spring Boot and its associations, such as Spring Cloud, Spring Data, and Spring Security.<\/p>\n\n\n\n<p>I have always been tempted to use the combination of Ctrl+C and task kill for the purpose of killing Spring Boot applications or processes. It can be automated by a batch script, but usually I was quite lazy to do this myself, as the combination of actions used to serve the purpose!&nbsp;<\/p>\n\n\n\n<p>Almost always on the command line, Ctrl+C kills the Spring Boot application process, although the outcome is very different on Eclipse IDE. The process outlives the Ctrl+C termination of Spring Boot applications, in the case of the IDE. <\/p>\n\n\n\n<p>Anyways, this unreliable and inconsistent outcome across platforms requires us to find standard or clean ways to shutdown Spring Boot applications and processes. <\/p>\n\n\n\n<p>Please note that this article is oriented toward the Windows operating system.<\/p>\n\n\n\n<p>GitHub Link to Clone Repository \/ Fork Code<br><a target=\"_blank\" href=\"https:\/\/github.com\/sumithpuri\/skp-spring-boot-shutdown\">https:\/\/github.com\/sumithpuri\/skp-spring-boot-shutdown<\/a><\/p>\n\n\n\n<p>Remember this article will explain ways to shutdown a Spring Boot application 'cleanly'. This means that terminating a Spring Boot application will also lead to its process being terminated, immediately. <\/p>\n\n\n\n<p>It is different from a graceful shutdown at the application level, where the application may need to perform certain actions or wait for a certain period of time to gracefully respond to current requests or to end current processing.<\/p>\n\n\n\n<p><strong>1. Terminate the Application, Kill the Process (Command Line) - IDE<\/strong><\/p>\n\n\n\n<p>You can verify this fact by issuing this command on the command-line<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">netstat -ao<\/pre>\n\n\n\n<p>You will get a screen such as the below. Locate the port on which you had started the Tomcat Server.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEgHTALnmpA7DEvZj6QxKQmwqKdjPPKLhKlZsw8ZnXz5r9ZiZqF6AIRO2IPSBmH5nhEmheRyCoJiiMOQJ0u9zehkl4XPav7aezTSiU8bQAoH8xu3lMzQQNQIIWvM6c-k7_owyzWB1D-KdnHA6467-79vdiNRC34ZKGf1zIlWj-7Pe9u7HiUOZoHt4ETlLw\" alt=\"\"\/><\/figure>\n<\/div>\n\n\n<p>Go ahead and locate the PID and kill the task (Windows\/MS-DOS)<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">taskkill \/F \/PID 14836<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEiS0214rgPJ0H8qP9HK8Eciiy9RNiE3qtqL9wOIXAO4hDX9x98oXi-BwPqyA7E0H0d2HUJOEZbnpfFTv_ed6_kUl39TjmCgHnI_UK1ktyx_FSOIKoEtYoKQMRzLZFYJJicBhKg9MhyRIOxVWg2WPoxbqXsd9F1iktbdc2xwUVY-eK2LH1LTYaDvegG5ow\" alt=\"\"\/><\/figure>\n<\/div>\n\n\n<p align=\"justify\">Note that if you were running the application from the command-line, You can just press [Ctrl+C] to terminate the application. In most cases, it will also kill the process. But if it does not kill the process, you should proceed with the above mentioned steps.<\/p>\n\n\n\n<div><b>[1a]<\/b>&nbsp;<u>Automate the writing of Process Id to a File<\/u><\/div>\n\n\n\n<p align=\"justify\">[The above mentioned task of finding out the process id associated with the application can be automated or programmed using the 'ApplicationPidFileWriter' as shown below. In the below example, when the server starts it will write the PID to the file name 'sbshutdownwin.pid'. Later, the same steps as described above can be followed to kill the process. Note that the steps can also be automated via Batch Scripting in Windows\/MS-DOS]<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> SpringApplication springBootapplication = new SpringApplication(SpringBootDockerApplication.class);  \n springBootapplication.addListeners(new ApplicationPidFileWriter(\"sbshutdownwin.pid\"));  \n springBootapplication.run();  <\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>2. Terminate the Application, Kill the Process (TCPView)<\/strong><\/p>\n\n\n\n<p align=\"justify\">There is one another way to immediately kill the process via the TCPView tool that is made available by Microsoft. It is available at this&nbsp;<a href=\"https:\/\/learn.microsoft.com\/en-us\/sysinternals\/downloads\/tcpview\" target=\"_blank\" rel=\"noreferrer noopener\">link<\/a>&nbsp;to download.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEjL9aie5-WPDlJOWLxVGPRzWlekHbKfkrEscRetmCcaL3OUOLq-txmjYPHeuBsl3s1DO1o8Pr_th2NcpT4HNH0GQsb0Py2luN3WZAXwqxN6jcuLB0m6AMWC4JgxXPHvpLu1kooRWx7Mk15q_SHjXV8LGstOtEZJXvTxln1IAwqpuWUV_qruJpzI7HAgGA=w640-h306\" alt=\"\"\/><\/figure>\n\n\n\n<p align=\"justify\">The next simple method is proposed by me. Beginby clicking on the [Terminate - Red Square in Eclipse on the Console Tab] button. You will observer that the application immediately shuts down. But infact at the background, the tomcat server will still be running on the port that it was started!<\/p>\n\n\n\n<p align=\"justify\">Use the above TCPView tool to locate the process based on the port on which you started the Tomcat Server\/Spring Boot Application. Right Click on the process\/row item and click on [Kill Process...] and then again Click on [OK] to confirm the killing of the operating system process.&nbsp;<\/p>\n\n\n\n<p align=\"justify\">This is a very convenient way especially if you are a Software Architect or an Engineer who has lots of Microservices to develop\/manage\/maintain. It will be useful when you are in depths of testing\/debugging\/fixing.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>3. Shutdown using Actuator Endpoint<\/strong><\/p>\n\n\n\n<p><p align=\"justify\">The most 'cleanest' way among the ones I described until now is the usage of Actuator to shutdown the spring boot applications. You will begin this by making sure to the include the following in your&nbsp;<strong>pom.xml<\/strong><\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEjMGD_-_KVzJC1S-8yY9xlkHawwdDSmQOEGGyJqG5M4w4GCqe1Hb1loq3cJK5ha6_lWkAGbdx79hzEXe7anYhn8ZOQKGw34ag9UCEjs3lNevzhEun_OjV8ZXijPAEfe42HLjGdJbqXVuVM8s8xWGglp3xwshOIPWbhDRQ_Q-PidNZUQRNkMoO4dtwHWBA=w400-h55\" alt=\"\"\/><\/figure>\n\n\n\n<p><p align=\"justify\">Next make sure that you have enabled the shutdown endpoint via actuator using the properties as shown below.<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEg4yZyksyu3xqAbAj44fheHcemCgQZNjGKqEjyrUtOyupBEGwmK5iWkORjloBSMlRnvrzkR_F-67CzLy2G3WS1j3GrVM_iwNqfGDaLZuvAsFdATgQOKxDChPkcwY-M8atwhl6tBo8jLDJFNucVGR5IlLq5MP8LmGfdW29cpM-4LQUpnbXlY8roNWYV9Ag=w640-h144\" alt=\"\"\/><\/figure>\n\n\n\n<p align=\"justify\">Once you have to shutdown the application, the actuator endpoint \/shutdown will also kill the associated process. This is a very clean way to shutdown the Spring Boot applications. You have to make sure that you invoke the actuator endpoint \/shutdown via a [POST] request only.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEjELC9xnk-jTPNkpKG4JHvEX64fM33ZNJPYh2K9uk0aF1nDfCpM1B_6TdYDehsaSdtuODU7eqBczYFciTj4IMj76oxYrnK2RGbNxDJ20a8BUxE9-XKxjYro056BO1jPeAXysyF75ydWPxLhcI-t3RJCps1j218jEq_avpiuI7bPElYFBPAT3Rl4xqdwRg=w640-h130\" alt=\"\"\/><\/figure>\n\n\n\n<p><p align=\"justify\">If Spring Boot is the root context of your spring boot application, then the invocation will look like the following. The above diagram shows the response from the request sent via Postman.<\/p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bat\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> http:\/\/localhost:8080\/springbootdocker\/actuator\/shutdown  <\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>4. Close the Spring Boot ApplicationContext<\/strong><\/p>\n\n\n\n<p><p align=\"justify\">The application context needs to be stored when you start\/run the spring boot application in your spring boot application class.<\/p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class SpringBootDockerApplication {  \n      \/\/ Clean Shutdown Method 2 - Actuator Shutdown Endpoint - Store the Context  \n      \/\/ Not a Recommended Way to Use public static - Only for the Demo Purposes..  \n      public static ConfigurableApplicationContext ctx;  \n      public static void main(String[] args) {  \n           \/\/ Clean Shutdown Method 2 - Actuator Shutdown Endpoint - Store the Context  \n           ctx = SpringApplication.run(SpringBootDockerApplication.class, args);  \n      }  \n }  \n<\/pre>\n\n\n\n<p><p align=\"justify\">You may then use the following controller method to close the context asynchronously. Also, note that a PreDestroy method has been added to do any cleanup.<\/p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">      \/\/ Starting Threads using Runnable is Not Always the Best Way..  \n      \/\/ Do Explore Other Integrated Approaches such as Async Servlet  \n      @RequestMapping(value = \"\/shutdown2\", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)  \n      public ResponseEntity&lt;Object> rule() {  \n           System.out.println(\"Entry Thread Id (Debug): \" + Thread.currentThread().getName());  \n           Runnable runnable= () -> {  \n                try {  \n                     Thread.sleep(2000);  \n                } catch (InterruptedException e) {  \n                       \n                     System.out.println(\"Thread was Interrupted! Error in Thread Sleep (2 Seconds!)\");  \n                }  \n                System.out.println(\"Callable Thread Id: \" + Thread.currentThread().getName());  \n                SpringBootDockerApplication.ctx.close();            \n           };  \n             \n           new Thread(runnable).start();  \n           System.out.println(\"Exit Thread Id (Debug): \" + Thread.currentThread().getName());  \n           return new ResponseEntity&lt;>(\"Shutdown Requested - Will Shutdown in Next 2 Seconds!\", HttpStatus.OK);  \n      }  \n   \n        \n   \n      @PreDestroy  \n      public void requestShutdown2PreDestroy() {  \n   \n           System.out.println(\"Requested Shutdown (via Context) of the Spring Boot Container\");  \n      }  <\/pre>\n\n\n\n<p><p align=\"justify\">Once the above has been done, built and deployed. You may then close the spring boot using the following browser request.<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEh3qfActZG-2gu9LjZ3e73WemtzCttIziJ3f181kiRhpCEGrtCGqjofhAjRJ8g4kN66KT_R5Ds2YurtYvb4sIHfpht0oT0vvpNnwlRVoHAKTJIlTjuOCM3E25AP9D6U_DevgY88dkj6GHxSzVnmhGsb2MmOj0fiJNMbKqEyVjMNfkBz69D_t-3W4K5cCg=w640-h122\" alt=\"\"\/><\/figure>\n\n\n\n<p><p align=\"justify\">You will notice that the application has been shutdown when you see the console and also the process has been removed from the operating system processes.<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjwooWQgGZkL8VyoA6LJ6Lzc51_Nq9KHvfveWJifqWK4Qm_24FzXOlfWVW0aqLHV8i7BB03IvsKmidWAnf83DUeyWP1wg1o5pG1o9eY7r7vUfLN8X4fRxzeSnD428cEak97SWoaUF0zxwOmSrFBfspKGx9GXVyhmK09NTG6H-RxtmkT548DPJV4ZiG3Qg\/w640-h70\/skp_ts_blog_001.png\" alt=\"\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>5. Exit using SpringApplication.exit()<\/strong><\/p>\n\n\n\n<p><p align=\"justify\">The other way is use the exit() method of the SpringApplication class, it will also require to use System.exit() for ending the process.&nbsp;<\/p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \/\/ Clean Shutdown Method 2 - Actuator Shutdown Endpoint - Store the Context   \n    \/\/ Not a Recommended Way to Use public static - Only for the Demo Purposes..   \n    private static ConfigurableApplicationContext ctx;   \n     \n    public static void main(String[] args) {   \n     \n       \/\/ Clean Shutdown Method 2 - Actuator Shutdown Endpoint - Store the Context   \n       ctx = SpringApplication.run(SpringBootDockerApplication.class, args);   \n    }   \n       \n    public static void exitApplication() {   \n       int staticExitCode = SpringApplication.exit(ctx, new ExitCodeGenerator() {   \n            \n        @Override   \n        public int getExitCode() {   \n        \/\/ no errors   \n        return 0;   \n        }   \n       });   \n       \n       System.exit(staticExitCode );   \n    }   <\/pre>\n\n\n\n<p><p align=\"justify\">The controller will look similar to what we had written previously. Once your application is running and you want to shutdown the application 'cleanly', then you may use the following:<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEhj9fdgrxzUzjulgrIX5hosG0H-nC0SgPcICf29E5Ld4p-R7omRSHNol4bAVVpClQ_B2dNYyLuD1rrCvSgQqWRKJGF5SbzM3_8VMNcKnDb3rJuH5_tg1w4DwGBPVHyIq0DfVlGGH4iy-RWhB1hKuxw6jxHF8MCd7yHzAcq3yCPkgTkwULetJ_nNQzWM9g=w640-h96\" alt=\"\"\/><\/figure>\n\n\n\n<p><p align=\"justify\">You will notice that the application has been shutdown when you see the console and also the process has been removed from the operating system processes.<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/a\/AVvXsEjEMWmzL03e0bjpDwxNE6sdx_-UnSfXugAZ1VNCNYucL1d35gmNJTZfCSQm1OUu8IOEAnkuvx4CHuuO4V7i6GzelBuq6AGzRqApL1OjwRlL5cj5HwYWig-OtAcXG2kceyPtMO9P5nd5sZTlkWZKtbTXl68n7bvBkdujThsxRsnSTTvBaDTNNwe81j5yXw=w640-h62\" alt=\"\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>[Reference]<\/strong><br><a href=\"https:\/\/www.javadevjournal.com\/spring-boot\/shutdown-spring-boot-application\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.javadevjournal.com\/spring-boot\/shutdown-spring-boot-application\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.<\/p>\n","protected":false},"author":168,"featured_media":50720,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[771,564],"tags":[1613,302,1612,1611],"class_list":["post-60055","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud","category-spring","tag-actuator","tag-spring-boot","tag-spring-boot-clean-shutdown","tag-spring-boot-shutdown"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Clean Ways to Shutdown Spring Boot Applications<\/title>\n<meta name=\"description\" content=\"Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Clean Ways to Shutdown Spring Boot Applications\" \/>\n<meta property=\"og:description\" content=\"Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/\" \/>\n<meta property=\"og:site_name\" content=\"foojay\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/sumith.puri\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-04T14:11:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-28T12:48:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/foojay.io\/wp-content\/uploads\/2021\/11\/1280px-Spring_Framework_Logo_2018.svg.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"329\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sumith Puri\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sumith Puri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/\"},\"author\":{\"name\":\"Sumith Puri\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/person\\\/49f84c9a4ae43b087ecee55b7a9f873b\"},\"headline\":\"Clean Shutdown of Spring Boot Applications\",\"datePublished\":\"2022-11-04T14:11:00+00:00\",\"dateModified\":\"2023-08-28T12:48:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/\"},\"wordCount\":932,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/1280px-Spring_Framework_Logo_2018.svg.png\",\"keywords\":[\"actuator\",\"spring boot\",\"spring boot clean shutdown\",\"spring boot shutdown\"],\"articleSection\":[\"Cloud\",\"Spring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/\",\"url\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/\",\"name\":\"Clean Ways to Shutdown Spring Boot Applications\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/1280px-Spring_Framework_Logo_2018.svg.png\",\"datePublished\":\"2022-11-04T14:11:00+00:00\",\"dateModified\":\"2023-08-28T12:48:39+00:00\",\"description\":\"Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#primaryimage\",\"url\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/1280px-Spring_Framework_Logo_2018.svg.png\",\"contentUrl\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/1280px-Spring_Framework_Logo_2018.svg.png\",\"width\":1280,\"height\":329},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/clean-shutdown-of-spring-boot-applications\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/foojay.io\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Clean Shutdown of Spring Boot Applications\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#website\",\"url\":\"https:\\\/\\\/foojay.io\\\/\",\"name\":\"foojay\",\"description\":\"a place for friends of OpenJDK\",\"publisher\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/foojay.io\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#organization\",\"name\":\"foojay\",\"url\":\"https:\\\/\\\/foojay.io\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/cropped-Favicon.png\",\"contentUrl\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/cropped-Favicon.png\",\"width\":512,\"height\":512,\"caption\":\"foojay\"},\"image\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/foojay2020\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/person\\\/49f84c9a4ae43b087ecee55b7a9f873b\",\"name\":\"Sumith Puri\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/B612_20191022_165846_426-removebg-preview-e1614235194334-96x96.png\",\"url\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/B612_20191022_165846_426-removebg-preview-e1614235194334-96x96.png\",\"contentUrl\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/B612_20191022_165846_426-removebg-preview-e1614235194334-96x96.png\",\"caption\":\"Sumith Puri\"},\"description\":\"Software Professional from India at Level of a [Principal Java\\\/J2EE Architect]. [Intro] https:\\\/\\\/bit.ly\\\/skp-tech-author\",\"sameAs\":[\"http:\\\/\\\/www.sumithpuri.xyz\",\"https:\\\/\\\/www.facebook.com\\\/sumith.puri\",\"http:\\\/\\\/instagram.com\\\/sumith.puri\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sumithpuri\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/sumith.puri\",\"https:\\\/\\\/x.com\\\/sumithpuri\",\"http:\\\/\\\/www,youtube.com\\\/@sumithpuri\"],\"url\":\"https:\\\/\\\/foojay.io\\\/today\\\/author\\\/sumith-puri\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Clean Ways to Shutdown Spring Boot Applications","description":"Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/","og_locale":"en_US","og_type":"article","og_title":"Clean Ways to Shutdown Spring Boot Applications","og_description":"Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.","og_url":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/","og_site_name":"foojay","article_author":"https:\/\/www.facebook.com\/sumith.puri","article_published_time":"2022-11-04T14:11:00+00:00","article_modified_time":"2023-08-28T12:48:39+00:00","og_image":[{"width":1280,"height":329,"url":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/11\/1280px-Spring_Framework_Logo_2018.svg.png","type":"image\/png"}],"author":"Sumith Puri","twitter_misc":{"Written by":"Sumith Puri","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#article","isPartOf":{"@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/"},"author":{"name":"Sumith Puri","@id":"https:\/\/foojay.io\/#\/schema\/person\/49f84c9a4ae43b087ecee55b7a9f873b"},"headline":"Clean Shutdown of Spring Boot Applications","datePublished":"2022-11-04T14:11:00+00:00","dateModified":"2023-08-28T12:48:39+00:00","mainEntityOfPage":{"@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/"},"wordCount":932,"commentCount":1,"publisher":{"@id":"https:\/\/foojay.io\/#organization"},"image":{"@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#primaryimage"},"thumbnailUrl":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/11\/1280px-Spring_Framework_Logo_2018.svg.png","keywords":["actuator","spring boot","spring boot clean shutdown","spring boot shutdown"],"articleSection":["Cloud","Spring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/","url":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/","name":"Clean Ways to Shutdown Spring Boot Applications","isPartOf":{"@id":"https:\/\/foojay.io\/#website"},"primaryImageOfPage":{"@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#primaryimage"},"image":{"@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#primaryimage"},"thumbnailUrl":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/11\/1280px-Spring_Framework_Logo_2018.svg.png","datePublished":"2022-11-04T14:11:00+00:00","dateModified":"2023-08-28T12:48:39+00:00","description":"Article discusses and presents five ways to shutdown Spring Boot apps cleanly. It provides inline code samples and link to GitHub.","breadcrumb":{"@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#primaryimage","url":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/11\/1280px-Spring_Framework_Logo_2018.svg.png","contentUrl":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/11\/1280px-Spring_Framework_Logo_2018.svg.png","width":1280,"height":329},{"@type":"BreadcrumbList","@id":"https:\/\/foojay.io\/today\/clean-shutdown-of-spring-boot-applications\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/foojay.io\/"},{"@type":"ListItem","position":2,"name":"Clean Shutdown of Spring Boot Applications"}]},{"@type":"WebSite","@id":"https:\/\/foojay.io\/#website","url":"https:\/\/foojay.io\/","name":"foojay","description":"a place for friends of OpenJDK","publisher":{"@id":"https:\/\/foojay.io\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/foojay.io\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/foojay.io\/#organization","name":"foojay","url":"https:\/\/foojay.io\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/foojay.io\/#\/schema\/logo\/image\/","url":"https:\/\/foojay.io\/wp-content\/uploads\/2020\/04\/cropped-Favicon.png","contentUrl":"https:\/\/foojay.io\/wp-content\/uploads\/2020\/04\/cropped-Favicon.png","width":512,"height":512,"caption":"foojay"},"image":{"@id":"https:\/\/foojay.io\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/foojay2020"]},{"@type":"Person","@id":"https:\/\/foojay.io\/#\/schema\/person\/49f84c9a4ae43b087ecee55b7a9f873b","name":"Sumith Puri","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/02\/B612_20191022_165846_426-removebg-preview-e1614235194334-96x96.png","url":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/02\/B612_20191022_165846_426-removebg-preview-e1614235194334-96x96.png","contentUrl":"https:\/\/foojay.io\/wp-content\/uploads\/2021\/02\/B612_20191022_165846_426-removebg-preview-e1614235194334-96x96.png","caption":"Sumith Puri"},"description":"Software Professional from India at Level of a [Principal Java\/J2EE Architect]. [Intro] https:\/\/bit.ly\/skp-tech-author","sameAs":["http:\/\/www.sumithpuri.xyz","https:\/\/www.facebook.com\/sumith.puri","http:\/\/instagram.com\/sumith.puri","https:\/\/www.linkedin.com\/in\/sumithpuri\/","https:\/\/in.pinterest.com\/sumith.puri","https:\/\/x.com\/sumithpuri","http:\/\/www,youtube.com\/@sumithpuri"],"url":"https:\/\/foojay.io\/today\/author\/sumith-puri\/"}]}},"_links":{"self":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/posts\/60055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/users\/168"}],"replies":[{"embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/comments?post=60055"}],"version-history":[{"count":0,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/posts\/60055\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/media\/50720"}],"wp:attachment":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/media?parent=60055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/categories?post=60055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/tags?post=60055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}