Bru*_*ros 63 java eclipse spring-boot
每次我在Eclipse IDE(Spring Tool Suite)中的调试模式下运行Spring Boot项目时,线程都会停止在"throw new SilentExitException();" 即使没有断点也行.
一些避免这种行为的解决方案?
org.springframework.boot.devtools.restart.SilentExitExceptionHandler.exitCurrentThread()(第53行):
public static void exitCurrentThread() {
throw new SilentExitException();
}
Run Code Online (Sandbox Code Playgroud)
这在升级到1.3.0里程碑后开始发生.
Spring Tool Suite版本:3.7.0.RELEASE Build Id:201506290649平台:Eclipse Luna SR2(4.4.2)
Phi*_*ebb 95
遗憾的是,这是新spring-boot-devtools模块的一个已知问题(请参阅https://github.com/spring-projects/spring-boot/issues/3100).我们使用这个技巧来杀死主线程,以便我们可以用可重新加载的版本替换它.到目前为止,我还没有找到防止调试断点触发的方法.
现在,您可以在Java - > Debug首选项中切换"暂停执行未捕获的异常"复选框以防止它发生.
小智 17
将该属性添加为 VM 参数:
-Dspring.devtools.restart.enabled=false
Run Code Online (Sandbox Code Playgroud)
这样您就不必更改代码,就像使用时一样:
System.setProperty("spring.devtools.restart.enabled", "false");
Run Code Online (Sandbox Code Playgroud)
由于Eclipse on Debug模式已经允许有限的热修补,因此我发现重新加载器在大多数情况下会适得其反,因此我决定通过以下方式禁用它:
System.setProperty("spring.devtools.restart.enabled", "false");
Run Code Online (Sandbox Code Playgroud)
参考:https : //docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable
由于该异常是由重新加载程序引发的,因此这也解决了此问题。请注意,您必须使用System.setProperty方法而不是在中进行设置application.properties。
我的解决方法:
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我们忽略 并不重要,SilentExitException因为开发工具只是使用 重新启动实例,而SilentExitException这并不是很安静。这个 try 块会让它安静下来......
我必须在类上使用文本匹配,因为它SilentExitException是私有的SilentExitExceptionHandler。
它并不能解决你的断点问题......
| 归档时间: |
|
| 查看次数: |
23108 次 |
| 最近记录: |