springboot的统一异常处理

springboot的统一异常处理

代码

@RestControllerAdvice
public class DefaultException {
    
    
    @ExceptionHandler
    ResultJson defaultExceptionHandler(Exception ex){
    
    
        ex.printStackTrace();
        return ResultJson.error(ex.getMessage());
    }
}

猜你喜欢

转载自blog.csdn.net/Ssucre/article/details/116703286