application.yml
spring:
redis:
host: 192.168.1.211
port: 6379
password: 123456
lettuce:
pool:
max-active: 8
max-idle: 8
max-wait: -1ms
min-idle: 0
shutdown-timeout: 100ms
server:
port: 8888
------------------------------------------
package com.example.java11boot;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisCacheTemplate(LettuceConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
GenericJackson2JsonRedisSerializerEx genericJackson2JsonRedisSerializerEx = new GenericJackson2JsonRedisSerializerEx();
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(genericJackson2JsonRedisSerializerEx );
template.setDefaultSerializer(genericJackson2JsonRedisSerializerEx );
template.setConnectionFactory(redisConnectionFactory);
return template;
}
class GenericJackson2JsonRedisSerializerEx implements RedisSerializer&l
SpringBoot + Redis (LocalDateTime保存问题)
最新推荐文章于 2022-10-21 16:31:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)