博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
优雅停止 SpringBoot 服务
阅读量:4182 次
发布时间:2019-05-26

本文共 1327 字,大约阅读时间需要 4 分钟。

package com.xiaobu.controller;import com.xiaobu.base.constant.Const;import com.xiaobu.base.utils.UrlShorterUtils;import com.xiaobu.entity.Url;import com.xiaobu.mapper.UrlMapper;import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.springframework.context.ApplicationContextAware;import org.springframework.context.ConfigurableApplicationContext;import org.springframework.web.bind.annotation.*;import javax.annotation.Resource;/** * @author xiaobu * @version JDK1.8.0_171 * @date on  2020/01/16 16:28 * @description */@RequestMapping("shutDown")@RestControllerpublic class ShutDownController implements ApplicationContextAware {
private ApplicationContext context; @GetMapping("/index") public String getIndex() {
return "OK"; } /** * 功能描述:停止服务 * @author xiaobu * @date 2020/1/16 16:55 * @return java.lang.String * @version 1.0 */ @GetMapping("/shutDownContext") public String shutDownContext() {
ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) context; ctx.close(); return "context is shutdown"; } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext; }}

转载地址:http://twgai.baihongyu.com/

你可能感兴趣的文章
writeb(), writew(), writel(),readb(), readw(), readl() 宏函数
查看>>
NOR Flash擦写和原理分析
查看>>
51单片机程序执行流程(STARTUP.A51)
查看>>
原码, 反码, 补码 详解
查看>>
Java自学第一阶段(二)- 小试牛刀
查看>>
Java自学第一阶段(三)- 万能的变量
查看>>
Java自学第一阶段(四)-万能的变量(2)
查看>>
HashMap存储原理以及与hashcode、equals方法的关系
查看>>
python3.6在windows下安装scrapy遇到的问题总结
查看>>
pycharm中打开scrapy项目,import scrapy报错问题
查看>>
scrapy爬取图片,自定义图片下载路径和图片名称
查看>>
python3下import MySQLdb出错问题
查看>>
Maven搭建SSM框架(eclipse)
查看>>
synchronized+Integer模拟火车票预售,出现的问题总结
查看>>
沉浸式过山车,感受巨蚁数字心灵的激情
查看>>
htmlunit爬取js异步加载后的页面
查看>>
修改Linux系统locale设置
查看>>
linux网络无法连接问题
查看>>
linux 查看ip
查看>>
go中map与xml互转
查看>>