注意点:
1.@ControllerAdvice
2.@ExceptionHandler
@ControllerAdvice
@Slf4j
public class ExceptionCatch {
@ResponseBody
@ExceptionHandler(Exception.class)
public ResponseResult GetException(Exception e){
System.out.println(e);
log.error("异常消息",e.getMessage());
return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERRRRRRRR);
}
}
@Configuration
@ComponentScan("com.heima.common.exception")
public class ExceptionConfig {
}
}