问题和这个类似 java - Spring basePackageClasses from @ControllerAdvice doesn't work - Stack Overflow
我自定义了一个注解,
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface BaseResponse {
}
在Controller类中加上了这个注解。
异常处理器中,加上了这个注解
@RestControllerAdvice(annotations = {BaseResponse.class})
对应的@ExceptionHandler方法并没有进行捕获处理
但如果把异常处理器的注解改成
@RestControllerAdvice
就能捕获了。
如果我需要指定捕获范围,该怎么做呢?求大神解答