SpringBoot @ExceptionHandler问题

为什么我的 @ExceptionHandler注解没有用????

img

引入的包是:import org.springframework.web.bind.annotation.ExceptionHandler;
还有你的类名改下换成其他的,你这个类名和注解重复了。

包引入出现问题吧,正确的包是:import org.springframework.web.bind.annotation.ExceptionHandler;

类名改成别的

这篇文章:SpringBoot异常处理 ExceptionHandler的使用 也许有你想要的答案,你可以看看