2
我在写一个Spring Boot应用程序。我现在正在执行异常处理。Java SpringBoot异常处理
我得到了以下问题。
我的异常处理程序是这样的:
@ControllerAdvice
public class SpecialExceptionHandler {
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseObject missingServletErrorHandler(HttpServletRequest req, MissingServletRequestParameterException exception) {
//do something
return responseObject;
}}
而且我得到了一个一般的异常处理程序看起来
@ControllerAdvice
public class GeneralExceptionHandler {
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseObject defaultErrorHandler(HttpServletRequest req, Exception exception) {
// do something
return responseObject;
}}
但是我有一个问题:我的应用程序经常遇到的GeneralExceptionHandler代替除非我将GeneralExceptionHandler类的名称更改为在特殊异常处理程序(例如,将'GeneralExceptionHandler'更改为'zGeneralExceptionHandler')后按字母顺序排列的名称。
我该如何解决这个问题?