Spring-boot:未到达 RestControllerAdvise

我已经建立了一个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 方法


有任何想法吗?


HUH函数
浏览 171回答 2
2回答

侃侃尔雅

您可能正在处理 DocumentAlreadyExistException 而不是将其抛出以供 spring 处理。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java