springboot全局异常处理

@RestControllerAdvice
@Slf4j
@ConditionalOnProperty(name = "global.exception.handle.config.enable", havingValue = "true")
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public JsonResult handleException(Exception e) {
        log.error("Error in service", e);
        return DefaultJsonResult.error("系统异常:" + e.getClass().getSimpleName());
    }
}

你可能感兴趣的:(springboot全局异常处理)