package com.*.data.busisystem.controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;
import com.*.data.busisystem.Lock; @RestController public class LockController { // 10 秒中,可以访问10次 @GetMapping("/test") @Lock public String lock() { // RedisAtomicInteger entityIdCounter = new RedisAtomicInteger("entityIdCounter", redisTemplate.getConnectionFactory()); // String date = DateFormatUtils.format(new Date(), "yyyy-MM-dd H:mm:ss.SSS"); try { System.out.println("加锁后,休眠前"); Thread.sleep(10000); System.out.println("加锁后,休眠后"); } catch (InterruptedException e) { e.printStackTrace(); } return "测试代码"; } }