diff --git a/pom.xml b/pom.xml
index f277e29..a673ac4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -139,6 +139,10 @@
fastjson2
2.0.51
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
diff --git a/xservice-cache/pom.xml b/xservice-cache/pom.xml
index b224e70..853dd12 100644
--- a/xservice-cache/pom.xml
+++ b/xservice-cache/pom.xml
@@ -8,6 +8,7 @@
xservice-basic
1.1-SNAPSHOT
+ 1.0-SNAPSHOT
xservice-cache
diff --git a/xservice-cache/src/main/java/com/xiang/xservice/basic/Main.java b/xservice-cache/src/main/java/com/xiang/xservice/basic/Main.java
deleted file mode 100644
index 983d37d..0000000
--- a/xservice-cache/src/main/java/com/xiang/xservice/basic/Main.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xiang.xservice.basic;
-
-//TIP To Run code, press or
-// click the icon in the gutter.
-public class Main {
- public static void main(String[] args) {
- //TIP Press with your caret at the highlighted text
- // to see how IntelliJ IDEA suggests fixing it.
- System.out.printf("Hello and welcome!");
-
- for (int i = 1; i <= 5; i++) {
- //TIP Press to start debugging your code. We have set one breakpoint
- // for you, but you can always add more by pressing .
- System.out.println("i = " + i);
- }
- }
-}
\ No newline at end of file
diff --git a/xservice-cache/src/main/java/com/xiang/xservice/cache/config/RedisConfig.java b/xservice-cache/src/main/java/com/xiang/xservice/cache/config/RedisConfig.java
new file mode 100644
index 0000000..c9b8f40
--- /dev/null
+++ b/xservice-cache/src/main/java/com/xiang/xservice/cache/config/RedisConfig.java
@@ -0,0 +1,48 @@
+package com.xiang.xservice.cache.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+
+@AutoConfiguration
+public class RedisConfig {
+ @Bean
+ @Primary
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(factory);
+
+ // 设置 key 和 hashKey 的序列化方式为 String
+ StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+ template.setKeySerializer(stringRedisSerializer);
+ template.setHashKeySerializer(stringRedisSerializer);
+
+ // 设置 value 和 hashValue 的序列化方式为 JSON 或其他合适格式
+ Jackson2JsonRedisSerializer