/** * 全局异常处理器 **/ @ControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(Exception.class) @ResponseBody public Map<String,Object> handlerException(Exception exception){ Map<String,Object> map = new HashMap<String ,Object>(); map.put("errorCode","500"); map.put("errorMsg",exception.toString()); return map; } }