本文共 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/