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();
andtemplate.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;
}