@RestController
public class RateLimiterController {
private RateLimiter rateLimiter = RateLimiter.create(10);
@RequestMapping("/test")
public void test() {
if(rateLimiter.tryAcquire(1000,TimeUnit.MILLISECONDS)){
System.out.println("请求成功");
}else {
System.out.println("等待超时,时间");
}
}
}