package com.pannk.demo; import com.pannk.demo.config.RedisUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.redis.core.RedisTemplate; /** * Created by wolf on 20-11-13. */ @Slf4j @SpringBootApplication public class App implements CommandLineRunner { @Autowired private RedisTemplate redisTemplate; @Autowired private RedisUtil redisUtil; public static void main(String[] args) { SpringApplication.run(App.class, args); } @Override public void run(String... args) { /*for (int i = 0; i < 1000; i++) { new Thread(() -> { String key = Thread.currentThread().getName(); redisTemplate.opsForValue().set(key, String.valueOf(Thread.currentThread().getId())); System.out.println("键值:" + key + " = " + redisTemplate.opsForValue().get(key)); }).start(); }*/ redisUtil.set("hello","okkk"); } }