'How can I catch SIGUSR2 in Java 11?

I want to catch SIGUSR1 or SIGUSR2 in my spring boot application and trigger a logic. Is there a way to do that?

Spring boot version - 2.6 , java version 11, Tomcat version 9.0.65



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source