Springbootはredisを統合し、文字化けした問題を解決します

最初に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 );
//
テンプレートを返す;
}
シリアル化後に文字化けした問題を解決する

 

おすすめ

転載: www.cnblogs.com/gpxs/p/12702731.html