1、在Springboot 中,统一异常处理主要是两个注解来完成
①:@RestControllerAdvice :是一个类似@RestController的注解,是把所有的web异常
进行拦截到当前类中。
②:@ExceptionHandler :把具体异常,给特定的处理方法上进行出来。
代码示例:


1、在Springboot 中,统一异常处理主要是两个注解来完成
①:@RestControllerAdvice :是一个类似@RestController的注解,是把所有的web异常
进行拦截到当前类中。
②:@ExceptionHandler :把具体异常,给特定的处理方法上进行出来。
代码示例: