Springboot 全局异常处理器


@RestControllerAdvice
public class ProjectExceptionAdvice {

//    拦截所有异常错误
    @ExceptionHandler
    public ApiRequest doException(Exception e){
        e.printStackTrace();//        输入异常到控制台
        return new ApiRequest(false,"服务器出现异常,请稍后再试");
    }
}