在common模块的pom文件中添加依赖
在MemberRegisterReg类中添加注解
MemberController中添加注解
新增自定义异常
/** * 校验异常统一处理 * @param e * @return */ @ExceptionHandler(value = BindException.class) @ResponseBody public CommonResp exceptionHandler(BindException e) { CommonResp commonResp = new CommonResp(); LOG.error("业务异常:{}", e.getBindingResult().getAllErrors().get(0).getDefaultMessage()); commonResp.setSuccess(false); commonResp.setMessage(e.getBindingResult().getAllErrors().get(0).getDefaultMessage()); return commonResp; }
将代码提交到git仓库