Files
springboot-common/src/main/java/cn/zhangdeman/annotation/CustomExceptionAnnotation.java

14 lines
947 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cn.zhangdeman.annotation;
import java.lang.annotation.*;
// 自定义异常注解
// 此注解会自动解析执行异常类, 将异常信息注册到 `HashMapCache` 中
@Retention(RetentionPolicy.RUNTIME) // 定带有注解类型的注解要保留多长时间。它需要一个RetentionPolicy参数可以是SOURCE、CLASS或 之一RUNTIME。例如@Retention(RetentionPolicy.RUNTIME)意味着注解应该由 JVM 保留,以便可以在运行时反射性地使用。
@Target(ElementType.TYPE) // 注解会施加在自定义异常类之上
@Inherited // @Inherited注解表示注解类型被自动继承。如果一个类被标注了@Inherited那么它的子类也会继承该注解。
public @interface CustomExceptionAnnotation {
String exceptionPackageList() default ""; // 哪些包下定义了异常类, 多个包路径用 , 分隔
String exceptionClassList() default ""; // 异常类路径, 多个类用 , 分隔
}