Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
张文彪
/
employmentBusinessPc
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4726ec1c
authored
Dec 05, 2025
by
tanzhiguo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改redis配置问题
parent
14c56833
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
employmentBusiness-pc-modules/employmentBusiness-pc-system/src/main/java/com/bkty/system/config/RedisConfig.java
employmentBusiness-pc-modules/employmentBusiness-pc-system/src/main/java/com/bkty/system/config/RedisConfig.java
View file @
4726ec1c
...
...
@@ -4,6 +4,7 @@ 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
...
...
@@ -14,12 +15,19 @@ public class RedisConfig {
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
template
.
setConnectionFactory
(
factory
);
// 使用 StringRedisSerializer 处理 Key 和 Value
StringRedisSerializer
stringRedisSerializer
=
new
StringRedisSerializer
();
template
.
setKeySerializer
(
stringRedisSerializer
);
template
.
setValueSerializer
(
stringRedisSerializer
);
template
.
setHashKeySerializer
(
stringRedisSerializer
);
template
.
setHashValueSerializer
(
stringRedisSerializer
);
// key 用字符串
StringRedisSerializer
stringSerializer
=
new
StringRedisSerializer
();
// value 使用 JSON 序列化,可兼容所有对象
GenericJackson2JsonRedisSerializer
jsonSerializer
=
new
GenericJackson2JsonRedisSerializer
();
// key
template
.
setKeySerializer
(
stringSerializer
);
template
.
setHashKeySerializer
(
stringSerializer
);
// value
template
.
setValueSerializer
(
jsonSerializer
);
template
.
setHashValueSerializer
(
jsonSerializer
);
template
.
afterPropertiesSet
();
return
template
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment