package com.zy.bms.config; import com.zy.bms.common.ServerResponse; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; /** * 全局异常拦截 * * @author chenyi * Create on 2019/10/21 */ @RestControllerAdvice public class ExceptionAdvice { /** * 对参数类型不匹配异常做统一拦截处理 */ @ExceptionHandler(value = MethodArgumentTypeMismatchException.class) public ServerResponse MethodArgumentTypeMismatchExceptionHandler() { return ServerResponse.error(); } }