首页>代码>Java开发小工具(集合遍历导出等方法):针对任何项目文件夹,可以递归遍历文件夹中的任何后缀名的文件,提取其中的中文>/springboot-01-cache/src/main/java/com/atguigu/cache/config/MyCacheConfig.java
package com.atguigu.cache.config; import com.atguigu.cache.bean.Employee; 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.Jackson2JsonRedisSerializer; import java.rmi.UnknownHostException; @Configuration public class MyCacheConfig { @Bean("mykeyGenerator") public RedisTemplate<Object, Employee> empRedisTemplate( RedisConnectionFactory redisConnectionFactory) throws UnknownHostException { RedisTemplate<Object, Employee> template = new RedisTemplate<Object, Employee>(); template.setConnectionFactory(redisConnectionFactory); Jackson2JsonRedisSerializer<Employee> ser = new Jackson2JsonRedisSerializer<Employee>(Employee.class); template.setDefaultSerializer(ser); return template; } }