我们正在运行spring启动应用程序作为后台进程,所以我们无法访问启动日志,在启动启动过程完成后,有什么方法可以知道吗?
发布于 2017-04-12 19:39:18
您可以选择在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即可。
http://docs.spring.io/spring-boot/docs/1.5.2.RELEASE/reference/htmlsingle/#boot-features-command-line-runner
https://stackoverflow.com/questions/43367390
复制相似问题