|
|
@@ -3,13 +3,9 @@ package com.ruoyi.common.redis.configure;
|
|
3
|
3
|
import java.nio.charset.Charset;
|
|
4
|
4
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
|
5
|
5
|
import org.springframework.data.redis.serializer.SerializationException;
|
|
6
|
|
-import org.springframework.util.Assert;
|
|
7
|
6
|
import com.alibaba.fastjson2.JSON;
|
|
8
|
7
|
import com.alibaba.fastjson2.JSONReader;
|
|
9
|
8
|
import com.alibaba.fastjson2.JSONWriter;
|
|
10
|
|
-import com.fasterxml.jackson.databind.JavaType;
|
|
11
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
12
|
|
-import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
13
|
9
|
|
|
14
|
10
|
/**
|
|
15
|
11
|
* Redis使用FastJson序列化
|
|
|
@@ -18,9 +14,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
18
|
14
|
*/
|
|
19
|
15
|
public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|
20
|
16
|
{
|
|
21
|
|
- @SuppressWarnings("unused")
|
|
22
|
|
- private ObjectMapper objectMapper = new ObjectMapper();
|
|
23
|
|
-
|
|
24
|
17
|
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
|
25
|
18
|
|
|
26
|
19
|
private Class<T> clazz;
|
|
|
@@ -53,15 +46,4 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|
53
|
46
|
|
|
54
|
47
|
return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
|
55
|
48
|
}
|
|
56
|
|
-
|
|
57
|
|
- public void setObjectMapper(ObjectMapper objectMapper)
|
|
58
|
|
- {
|
|
59
|
|
- Assert.notNull(objectMapper, "'objectMapper' must not be null");
|
|
60
|
|
- this.objectMapper = objectMapper;
|
|
61
|
|
- }
|
|
62
|
|
-
|
|
63
|
|
- protected JavaType getJavaType(Class<?> clazz)
|
|
64
|
|
- {
|
|
65
|
|
- return TypeFactory.defaultInstance().constructType(clazz);
|
|
66
|
|
- }
|
|
67
|
49
|
}
|