Breakpoint at “throw new SilentExitException()” in Eclipse + Spring Boot

前端 未结 5 823
Happy的楠姐
Happy的楠姐 2021-01-30 19:35

Every time I run my Spring Boot project on debug mode in Eclipse IDE (Spring Tool Suite), the thread stops at throw new SilentExitException(); line even without a b

5条回答
  •  天涯浪人
    2021-01-30 19:54

    My workaround:

    public static void main(String[] args) {
        try {
            SpringApplication.run(App.class, args);
        } catch (Throwable e) {
            if(e.getClass().getName().contains("SilentExitException")) {
                LOGGER.debug("Spring is restarting the main thread - See spring-boot-devtools");
            } else {
                LOGGER.error("Application crashed!", e);
            }
        }
    }
    

    It doesn't matter that we ignore the SilentExitException because the devtools are just restarting the instance with a SilentExitException which isn't very silent. This try block will silence it...

    I had to use text matching on the class as the SilentExitException is private in SilentExitExceptionHandler.

    It doesn't solve your problem with the breakpoint...

提交回复
热议问题