目的
利用 自定义注解、Spring Aop、Guava Cache 实现表单防重复提交...
导入依赖
在 pom.xml 中添加上 spring-boot-starter-web 、com.google.guava的依赖即可
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-aop
com.google.guava
guava
28.0-jre
Lock 注解
自定义LocalLock注解(其中key值可以根据自身需求自定义生成规则)
package com.annotation;
import java.lang.annotation.*;
/**
* @description: 自定义本地锁的注解
* @author: Dai Yuanchuan
* @create: 2019-08-29 23:38
**/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface LocalLock {
/**
* @author 本地锁的key值
*/
String key() default "";
}
Lock 拦截器(AOP)
package com.inter