【发布时间】:2019-08-28 15:40:40
【问题描述】:
我为我的 REST 服务使用 @ControllerAdvice。但是我无法获得完整的堆栈跟踪并定义异常发生的位置。
我的控制器建议:
@ControllerAdvice
public class RestResponseEntityExceptionHandler
extends ResponseEntityExceptionHandler {
@ExceptionHandler(value = {Exception.class})
protected ResponseEntity<Object> handleException(
Exception ex, WebRequest request) {
String bodyOfResponse = "Internal error";
System.out.println(ex.toString());
return handleExceptionInternal(ex, bodyOfResponse,
new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
}
}
如果发生异常,我只会收到:
警告 72490 --- [nio-5054-exec-2] .m.m.a.ExceptionHandlerExceptionResolver :已解决 [java.lang.NullPointerException]
如何获得完整的堆栈跟踪?
【问题讨论】:
标签: spring-boot controller-advice