43 lines
1.3 KiB
Java
43 lines
1.3 KiB
Java
|
|
package com.wms;
|
|||
|
|
|
|||
|
|
import org.springframework.boot.ApplicationArguments;
|
|||
|
|
import org.springframework.boot.SpringApplication;
|
|||
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|||
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|||
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
|
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
|
|
|
|||
|
|
@SpringBootApplication()
|
|||
|
|
@EnableScheduling
|
|||
|
|
@EnableTransactionManagement
|
|||
|
|
@EnableAsync
|
|||
|
|
public class WmsApplication {
|
|||
|
|
/**
|
|||
|
|
* 用于重启程序的上下文
|
|||
|
|
*/
|
|||
|
|
private static ConfigurableApplicationContext context;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 主函数,程序的入口
|
|||
|
|
*
|
|||
|
|
* @param args 命令行参数,以字符串数组形式传入
|
|||
|
|
*/
|
|||
|
|
public static void main(String[] args) {
|
|||
|
|
context = SpringApplication.run(WmsApplication.class, args);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 重启程序
|
|||
|
|
*/
|
|||
|
|
public static void restart() {
|
|||
|
|
ApplicationArguments args = context.getBean(ApplicationArguments.class);
|
|||
|
|
Thread thread = new Thread(() -> {
|
|||
|
|
context.close();
|
|||
|
|
context = SpringApplication.run(WmsApplication.class, args.getSourceArgs());
|
|||
|
|
});
|
|||
|
|
thread.setDaemon(false);
|
|||
|
|
thread.start();
|
|||
|
|
}
|
|||
|
|
}
|