java spring boot static 中如何 @Autowired

采用构造函数注入

public class ConnectionUtil{
    public static RedisCache redisCache;
    @Autowired
    public ConnectionUtil(RedisCache _redisCache){
        ConnectionUtil.redisCache=_redisCache;
    }
}
posted @ 2022-11-25 14:50  fishpro  阅读(230)  评论(0编辑  收藏  举报