简体   繁体   English

使用Intellij Idea捕获Spring-boot应用程序的外部jar停止事件

[英]Catch external jar stop event for Spring-boot application with Intellij Idea

to launch my Spring Boot application in production environment my company has a system that executes "java -jar" and I'm trying to simultate it in my Intellij idea and jar starts correctly and I can debug with proyect source too. 为了在生产环境中启动我的Spring Boot应用程序,我公司有一个执行“ java -jar”的系统,我试图以Intellij的方式对其进行仿真,然后jar正确启动,我也可以使用proyect源进行调试。

In run and debug mode, when I click in stop button the jar is stopped suddenly with the message: 在运行和调试模式下,当我单击“停止”按钮时,jar突然停止,并显示以下消息:

Disconnected from the target VM, address: '127.0.0.1:58575', transport: 'socket'

Process finished with exit code -1

And I can´t catch the close event to close my DB connections. 而且我无法捕获close事件来关闭我的数据库连接。 I've tryed other stackoverflow solutions like PortalServiceLifeCycle , @PreDestroy and setRegisterShutdownHook(false) in SpringApplication run in main . 我tryed其他计算器解决方案,如PortalServiceLifeCycle@PreDestroy在SpringApplication运行在主setRegisterShutdownHook(假)

Jar is created by Maven with clean and package goals and we haven't xml spring configurations, only annotations. Jar是由Maven创建的,具有干净的和打包的目标,我们没有xml spring配置,只有注释。

What I need to catch shutdown service to close connections? 我需要关闭服务来关闭连接吗?

Edit: Add my Intellij buttons: 编辑:添加我的Intellij按钮:

在此处输入图片说明

Thank you. 谢谢。

Please check this answer . 检查此答案

This feature is not available in Debug mode yet. 此功能在调试模式下尚不可用

This feature is also not available for JAR run configuration, but is available for Application run configuration. 该功能也不适用于JAR运行配置,但适用于应用程序运行配置。

You can use remote debug and Ctrl+C in the external console to debug the code in the shutdown hooks until IDEA-171093 is implemented. 您可以在外部控制台中使用远程调试和Ctrl + C调试关闭挂钩中的代码,直到实现IDEA-171093

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM