av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

spring boot 如何優雅關閉服務

瀏覽:5日期:2023-08-03 13:21:09

spring boot 優雅的關閉服務

實現ContextClosedEvent 監聽器,監聽到關閉事件后,關閉springboot進程

**網上有很多例子 使用spring boot 插件做關閉經測試此插件只能是關閉spring boot服務,不能殺死服務進程。還是需要實現關閉監聽,去殺死進程。網上有很多例子 使用spring boot 插件做關閉經測試此插件只能是關閉spring boot服務,不能殺死服務進程。還是需要實現關閉監聽,去殺死進程。網上有很多例子 使用spring boot 插件做關閉經測試此插件只能是關閉spring boot服務,不能殺死服務進程。還是需要實現關閉監聽,去殺死進程。重要的事說三遍**

actuator 關閉spring boot 實現方式引入actuator 配置 shutdown調用http://127.0.0.1/xxx/

引入actuator<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>-->

配置在application.properties中開啟關閉management.endpoints.web.exposure.include=*#management.endpoint.shutdown.enabled = true

1.調用

1.主入口public static ConfigurableApplicationContext configurableApplicationContext;public static void main(String[] args) throws InterruptedException { configurableApplicationContext = SpringApplication.run(GatewayApplication.class, args);}2.關閉監聽@Controllerpublic static class ShutdownAction implements ApplicationListener<ContextClosedEvent> {@Overridepublic void onApplicationEvent(ContextClosedEvent event) {System.exit(SpringApplication.exit(configurableApplicationContext));}}3.關閉服務命令 /** * 關閉服務 */ @RequestMapping(value = '/stop', method = RequestMethod.GET) @ResponseBody public void stopServer() { MySpringApplication.configurableApplicationContext.close(); }

到此這篇關于spring boot 如何優雅關閉服務的文章就介紹到這了,更多相關spring boot 關閉服務 內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 亚洲精品久久久久久久久久吃药 | 国产乱码一二三区精品 | 久久国 | 337p日本欧洲亚洲大胆鲁鲁 | 亚洲欧美中文日韩在线 | 国产一级片网站 | av在线播放不卡 | 婷婷五月色综合香五月 | 日韩av在线播 | 国产在线精品免费 | 日本高清视频在线播放 | 成人综合伊人 | 婷婷色国产偷v国产偷v小说 | 中文字幕一区在线 | 亚洲免费观看 | 91在线看 | 成人二区| 免费a网站 | 一区二区三区四区在线 | 九九视频在线观看视频6 | 国产成人99久久亚洲综合精品 | 国产在线观看 | 蜜桃av人人夜夜澡人人爽 | www成人免费视频 | 81精品国产乱码久久久久久 | 亚州春色 | 亚洲影音| 久久久91精品国产一区二区三区 | 国产美女一区二区三区 | av国产精品| 亚洲精品乱码久久久久久蜜桃 | 综合五月 | 国产aⅴ精品 | 6996成人影院网在线播放 | 国产三级在线观看播放 | 日韩欧美专区 | 亚洲第一视频网站 | 日韩欧美在线一区 | 91精品国产91久久久 | 久久久久免费 | 国产精品嫩草影院精东 |