Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Spring Data Redis Refactor

$
0
0

I've made a terrible mistake with Spring Data Redis. When I refactor my code and move @RedisHash classes to different package, Spring Data is unable to find @RedisHash'es which are already present in database.

  • Is there any simple way how to fix this?
  • I am now aware of template.setKeySerializer(); and template.setHashKeySerializer(); How should I set these to allow me to refactor (rename or move to different package) my @RedisHash-annotated classes?

This is configuration I am using.

@Configuration
public class RedisConfiguration {

   @Bean
   JedisConnectionFactory jedisConnectionFactory() {
      RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
      config.setHostName("127.0.0.1");
      config.setPort(6379);
      return new JedisConnectionFactory(config);
   }

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

}

and one sample of my @RedisHash'es

@Data
@RedisHash("StringKV")
public class StringKV implements Serializable {

   private String id;
   private String value;

}

Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>