由于ExceptionHandlerExceptionResolver,代码未打印堆栈跟踪信息

问题描述 投票:0回答:1

我正在调试Spring Boot应用程序,但是发现这样做非常困难,因为我的代码没有打印任何堆栈跟踪:no stack trace printed for ArrayOOB exception, so I have no idea where it happened

ExceptionHandlerExceptionResolver到底是什么,和我的问题有关系吗?

exception handler
1个回答
0
投票

ExceptionHandlerExceptionResolver将未捕获的异常与这两个处理程序(控制器)上都合适的@ExceptionHandler方法以及任何控制器建议。

更多详细信息https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc##extending-exceptionhandlerexceptionresolver

我和您一样面临着同样的问题。就我而言,我使用@ControllerAdvice,但没有Exception.class处理程序案例。

添加后,将再次打印stacktrace。

@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseEntity<Object> handleException(Exception e) {
    LOGGER.error("Exception: {}", e);
    // your handler code.
}
© www.soinside.com 2019 - 2024. All rights reserved.