1

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.

In run and debug mode, when I click in stop button the jar is stopped suddenly with the message:

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. I've tryed other stackoverflow solutions like PortalServiceLifeCycle, @PreDestroy and setRegisterShutdownHook(false) in SpringApplication run in main.

Jar is created by Maven with clean and package goals and we haven't xml spring configurations, only annotations.

What I need to catch shutdown service to close connections?

Edit: Add my Intellij buttons:

enter image description here

Thank you.

Corporativo
  • 185
  • 1
  • 2
  • 11

1 Answers1

0

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.

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.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904