转自:SpringBoot 项目在静态工具类中注入 Redis_Kung's blog column-CSDN博客_redis静态工具类
如在工具类 Sm4EncryptUtil 中注入redis:
@Component public class Sm4EncryptUtil { @Autowired private static RedisUtil redisUtil; @Autowired public void setRedisService(RedisUtil redisService) { Sm4EncryptUtil.redisUtil = redisService; } }