最初にpom.xmlファイルを変更します
<dependencies>
<dependency>
<groupId> org.springframework.boot </ groupId>
<artifactId> spring-boot-starter-web </ artifactId>
</ dependency>
<dependency>
<groupId> org.springframework.boot </ groupId>
<artifactId> spring-boot-starter-test </ artifactId>
<scope> test </ scope>
</ dependency>
<!-redis->
<dependency>
< groupId > org.springframework.boot </ groupId>
<artifactId> spring-boot-starter-data-redis </ artifactId>
</ dependency>
</ dependencies>
構成完了後新增豆配置类RedisConfig
@構成
パブリッククラスRedisConfig {
@Bean (name = "redisTemplate" )
public RedisTemplate < 文字列、文字列> redisTemplate (RedisConnectionFactory ファクトリ){
RedisTemplate < 文字列、文字列> テンプレート= 新しいRedisTemplate <>();
RedisSerializer < 文字列> redisSerializer = new StringRedisSerializer ();
テンプレート。setConnectionFactory (factory );
//キーのシリアル化
テンプレート。setKeySerializer (redisSerializer );
//値のシリアル化
テンプレート。setValueSerializer (redisSerializer );
//ハッシュマップのシリアライズ値
テンプレート。setHashValueSerializer (redisSerializer );
//キーhaspmapシリアル化
テンプレート。setHashKeySerializer (redisSerializer );
//
テンプレートを返す;
}
シリアル化後に文字化けした問題を解決する