SpringBoot2.x整合Redis缓存自定义序列化
一、导入Jar包 <!-- redis --><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId></dependency> <!-- 缓存依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-start-cache</artifactId> </dependency> 二、配置文件 /** * reids配置类 */ @Configuration @EnableCaching public class RedisConfig extends CachingConfigurerSupport{ @Bean public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(factory);