3
我们将Spring引导应用程序作为后台进程运行,所以我们无法访问启动日志,在启动启动过程完成后有没有办法知道?Spring引导启动监听程序
我们将Spring引导应用程序作为后台进程运行,所以我们无法访问启动日志,在启动启动过程完成后有没有办法知道?Spring引导启动监听程序
你可以选择在spring启动过程完成启动后执行一些代码,当启动完成时你可以发送关于启动完成的通知。
@SpringBootApplication
@Component
public class Application implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... arg0) throws Exception {
// You can write your code here.
// This code will be executed after Spring Boot Startup completed.
}
}
只是执行CommandLineRunner,如上所示。