@SpringBootApplication
public class SpringbootRestartDemoApplication {

     private static ConfigurableApplicationContext context;

     public static void main(String[] args) throws InterruptedException {
          context = SpringApplication.run(SpringbootRestartDemoApplication.class, args);
     }


     /**
      * 重新启动
      */
     public static void restart() {
          ApplicationArguments args = context.getBean(ApplicationArguments.class);

          Thread thread = new Thread(() -> {
                SpringApplication.exit(context, () -> 0);
                context = null;
                context = SpringApplication.run(SpringbootRestartDemoApplication.class, args.getSourceArgs());
          });

          thread.setDaemon(false); // 不标记守护线程
          thread.start();
     }
}

when I use this method to restart applicationContext , I mean ,can I restart new ApplicationContext ,Not is reuse ConfigurableApplicationContext. I really need you help , thanks!

Comment From: wilkinsona

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.