Files
springboot-demo/src/main/java/com/example/demo/aop/RateLimited.java
likingcode 539dc41868 feat: Spring Boot示例项目
- 基础Spring Boot配置
- Docker支持
2026-03-07 05:43:15 +00:00

28 lines
572 B
Java

package com.example.demo.aop;
import java.lang.annotation.*;
/**
* 限流注解 - 自定义注解配合 AOP 使用
*
* 学习点:
* - 自定义注解定义
* - @Retention 保留策略
* - @Target 目标元素
* - 注解 + AOP 实现声明式功能
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface RateLimited {
/**
* 每分钟最大请求数
*/
long value() default 100;
/**
* 限流提示消息
*/
String message() default "请求过于频繁,请稍后再试";
}