redis spring启动:未能使用defaultserializer序列化对象

ukxgm1gy  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(266)

我的服务方式

@Cacheable(value = "taskAndChildren", key = "#taskId")
  public TaskTreeResponse getTasks(String taskId, Integer depth) {
    log.info("Method entered");
    return tasksApi.getTasks(taskId, depth);
  }

我的应用程序.java

@EnableCaching
 @SpringBootApplication(
exclude = {
  ErrorMvcAutoConfiguration.class,
  SecurityAutoConfiguration.class,
  RedisAutoConfiguration.class
},
scanBasePackages = {"io.mycompany"})

公共类应用程序{}
缓存配置

@Configuration
@Profile("cache")
public class CacheConfig {

 @Bean
 JedisConnectionFactory jedisConnectionFactory() {
  return new JedisConnectionFactory();
}

 @Bean
 public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(jedisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
return template;
}
}

tasktreeresponse不是我的类,因此无法使其序列化

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题