1、建立ShutdownUtil工具类
@Component
public class ShutdownUtil implements ApplicationContextAware {
    Logger logger = LoggerFactory.getLogger(ShutdownUtil.class);
    private ConfigurableApplicationContext context;
    public void shutdown() {
        if (Objects.nonNull(context)) {
            logger.info("###########开始关闭系统############");
            context.close();
        }
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (applicationContext instanceof ConfigurableApplicationContext) {
            this.context = (ConfigurableApplicationContext) applicationContext;
        }
    }
}
2、引用ShutdownUtil工具类
    @Autowired
    ShutdownUtil shutdownUtil;
    @PostMapping("/shutdown")
    public ResponseBaseVO shutdownApp(){
        ResponseBaseVO responseBaseVO = ResponseBaseVO.ok();
        shutdownUtil.shutdown();
        return responseBaseVO;
    }