@Component public class MyApplicationEvent implements ApplicationListener
@Override public void onApplicationEvent(ApplicationEvent applicationEvent) { if(applicationEvent instanceof ContextClosedEvent){ System.out.println("------------------"); System.out.println("----开始关闭---"); System.out.println("----已经关闭----"); System.out.println("------------------"); } }
}
为啥 debug 的时候关闭服务,控制台会打印这个输出 run 的时候关闭服务,就什么也不打印,这玩意是要在哪里设置的嘛?
![]() | 1 guyeu 2020-04-23 11:49:12 +08:00 打印不打印大概是 sigterm 或 sigkill 的区别。。和 debug/run 关系不大 |
![]() | 3 MotherShip 2020-04-23 13:46:35 +08:00 |
![]() | 4 jmc891205 2020-04-23 13:53:39 +08:00 看下你的 run/debug configuration 怎么设的 |
5 Jirajine 2020-04-23 13:54:35 +08:00 via Android 应该是一楼说的 signal 的原因。大概区别就是一个是告诉程序让它自己退出,一个是告诉操作系统强行杀掉进程。 详细可以看这篇关于 tty 的文章: https://program-think.blogspot.com/2019/11/POSIX-TUI-from-TTY-to-Shell-Programming.html |
![]() | 6 luxinfl OP @MotherShip 你这没运行完就打印出来了??我 run 和 debug 的时候,没有运行好直接停止,都不会打印。。 |
![]() | 9 MotherShip 2020-04-23 15:12:10 +08:00 @luxinfl #6 我没加 web-start,所以跑起来直接停了。。 |