From 92edf51b040f057afa1fece88e0fbcd559baa27f Mon Sep 17 00:00:00 2001
From: songhuangfeng123 <shf18767906695@163.com>
Date: 星期二, 05 七月 2022 11:32:49 +0800
Subject: [PATCH] 初始化运行

---
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisConfig.java |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisConfig.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisConfig.java
new file mode 100644
index 0000000..783b5f2
--- /dev/null
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/redis/RedisConfig.java
@@ -0,0 +1,43 @@
+package com.gkhy.safePlatform.config.redis;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig  {
+
+
+
+    /**
+    * @Description: key和value的序列化方式
+    */
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
+
+        RedisTemplate<String, Object> template = new RedisTemplate<>();
+        template.setConnectionFactory(factory);
+        // json序列化对象
+        GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
+        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+        // key=>string
+        template.setKeySerializer(stringRedisSerializer);
+        // hash=>string
+        template.setHashKeySerializer(stringRedisSerializer);
+        // value=>json
+        template.setValueSerializer(jackson2JsonRedisSerializer);
+        // hashValue=>json
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
+        // set
+        template.afterPropertiesSet();
+        return template;
+    }
+
+
+
+
+
+}

--
Gitblit v1.9.2