From 01c93f2d02c0b845640c3b787665ee54cbec4b17 Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Mon, 18 Jan 2021 22:27:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=B0docker=E5=A4=96?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/telpo/dipperposition/common/OkHttpUtil.java | 13 +++++-------- .../com/telpo/dipperposition/common/RedisUtil.java | 8 +++++--- 2 files changed, 10 insertions(+), 11 deletions(-) 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============================ /**