aop+redis实现ip请求方法防刷
- 引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- aop -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
- 修改配置文件
spring:
redis:
host: localhost
port: 6379
database: 1
password:
timeout: 5000ms
- 创建一个限流的注解
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME