You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gym/LoginUser.java

25 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 定义该文件所在的包路径,在 Java 里,包是组织类和接口的一种方式,此包路径为 com.annotation能防止命名冲突也便于代码的管理与维护
package com.annotation;
// 导入 java.lang.annotation.ElementType 类,它是一个枚举类型,包含了多种不同的元素类型,像类、方法、字段等,在定义注解时可借助它来指定注解的作用目标
import java.lang.annotation.ElementType;
// 导入 java.lang.annotation.Retention 注解,它用于指定注解的保留策略,也就是注解在不同阶段的存活时间和可见性
import java.lang.annotation.Retention;
// 导入 java.lang.annotation.RetentionPolicy 枚举类,它定义了三种保留策略,分别是 SOURCE仅在源码中保留、CLASS在编译后的字节码文件中保留但运行时不可用、RUNTIME在运行时也保留可通过反射机制获取
import java.lang.annotation.RetentionPolicy;
// 导入 java.lang.annotation.Target 注解,它用于指定自定义注解可以应用的目标元素类型,与 ElementType 结合使用,能精确控制注解的使用范围
import java.lang.annotation.Target;
// 登录用户信息注解
// 用于标识Controller方法中需要注入当前登录用户信息的参数
@Target(ElementType.PARAMETER)
// 指定该注解只能用于方法参数上
@Retention(RetentionPolicy.RUNTIME)
// 指定该注解在运行时保留,可以通过反射读取
public @interface LoginUser {
// 这是一个标记注解,不包含任何属性
// 用于标识需要自动注入当前登录用户信息的参数
}