我已经建立了一个RestControlerAdvise:
@RestControllerAdvice
@Order(Ordered.HIGHEST_PRECEDENCE)
public class ExceptionControllerAdvice {
@ExceptionHandler({DocumentAlreadyExistsException.class})
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public cat.gencat.ctti.canigo.arch.web.rs.model.Error handleException(DocumentAlreadyExistsException e) {
cat.gencat.ctti.canigo.arch.web.rs.model.Error error = new cat.gencat.ctti.canigo.arch.web.rs.model.Error();
error.setCode(HttpStatus.BAD_REQUEST.value());
error.setMessage(e.getMessage());
return error;
}
}
尽管如此,即使我提出了DocumentAlreadyExistException.
在启动时检测到:
2018-08-20 17:08:25.791 INFO 4941 --- [main] .mmaExceptionHandlerExceptionResolver:在 exceptionControllerAdvice 中检测到 @ExceptionHandler 方法
有任何想法吗?
侃侃尔雅
相关分类