diff --git a/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java b/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java index 9063e5c..2452e02 100644 --- a/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java +++ b/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java @@ -8,6 +8,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.text.MessageFormat; import java.util.Iterator; import java.util.Map; @@ -26,15 +27,11 @@ public class OkHttpUtil { @Autowired private OkHttpClient okHttpClient; private static OkHttpUtil okHttpUtil; - /** - * spring会自动从ioc容器当中根据OkHttpUtil类型找到okHttpUtil,当做参数传进来 - * - */ - @Autowired - public void setOkHttpUtil(OkHttpUtil okHttpUtil) { - this.okHttpUtil = okHttpUtil; - } + @PostConstruct + public void init() { + okHttpUtil = this; + } /** * 根据map获取get请求参数 * diff --git a/src/main/java/com/telpo/dipperposition/common/RedisUtil.java b/src/main/java/com/telpo/dipperposition/common/RedisUtil.java index 8ef86a5..107ace8 100644 --- a/src/main/java/com/telpo/dipperposition/common/RedisUtil.java +++ b/src/main/java/com/telpo/dipperposition/common/RedisUtil.java @@ -6,6 +6,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.List; import java.util.Map; @@ -29,9 +30,10 @@ public class RedisUtil { * spring会自动从ioc容器当中根据RedisUtil类型找到redisUtil,当做参数传进来 * */ - @Autowired - public void setRedisUtil(RedisUtil redisUtil) { - this.redisUtil = redisUtil; + + @PostConstruct + public void init() { + redisUtil = this; } // =============================common============================ /**