我将 @ControllerAdvice 用于我的 REST 服务。但是我无法获得完整的堆栈跟踪并定义发生异常的位置。
我的控制器建议:
@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);
}
}
如果发生异常,我只会收到:
WARN 72490 --- [nio-5054-exec-2] .mmaExceptionHandlerExceptionResolver:已解决 [java.lang.NullPointerException]
如何获得完整的堆栈跟踪?