From 73ad14eba38160802fd986252190fd8b823efc8d Mon Sep 17 00:00:00 2001 From: lyfO_o <764716047@qq.com> Date: 星期一, 04 七月 2022 18:15:08 +0800 Subject: [PATCH] 调整 --- safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisUtils.java | 11 +++++++++++ safePlatfrom-out-web/src/main/resources/config/application-dev.yaml | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisUtils.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisUtils.java index 08fe8f7..d185143 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisUtils.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisUtils.java @@ -12,6 +12,7 @@ import org.springframework.data.redis.core.*; import org.springframework.stereotype.Repository; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.io.Serializable; import java.util.HashSet; @@ -37,6 +38,16 @@ private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @PostConstruct + public void initRepository(){ + try { + this.set("test:module:Web", "testConnection", 60L, TimeUnit.SECONDS); + logger.info("[ModuleRedis][Web] is connected"); + } catch (Exception e) { + logger.error("[ModuleRedis][Web] connected failed!!"); + } + } + /** * 写入缓存 * @param key diff --git a/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml b/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml index 8bb6864..589bb65 100644 --- a/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml +++ b/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml @@ -22,9 +22,9 @@ password: Adsdf675T6AC7yga type: com.alibaba.druid.pool.DruidDataSource redis: - host: 127.0.0.1 + host: 192.168.0.52 port: 6379 - password: root # Redis 服务器密码,默认为空。生产中,一定要设置 Redis 密码! + password: SEF98uvs98dUAUEF90Udssa database: 0 # Redis 数据库号,默认为 0 timeout: 15000 # Redis 连接超时时间,单位:毫秒。 # 对应 RedisProperties.Jedis 内部类 -- Gitblit v1.9.2