Adding Java config

This commit is contained in:
sameira
2016-01-22 08:44:58 +05:30
parent 97ca1980ac
commit bc7240ead1
4 changed files with 54 additions and 23 deletions
@@ -0,0 +1,21 @@
package org.baeldung.spring.data.redis.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@Configuration
public class RedisConfig {
@Bean
JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate< String, Object> redisTemplate() {
final RedisTemplate< String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(jedisConnectionFactory());
return template;
}
}
@@ -7,7 +7,7 @@ public class Student implements Serializable {
private static final long serialVersionUID = -1907106213598514113L;
public enum Gender {
Male, Female
MALE, FEMALE
}
private String id;
@@ -2,16 +2,18 @@ package org.baeldung.spring.data.redis.repo;
import org.baeldung.spring.data.redis.model.Student;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;
import java.util.Map;
@Repository
public class StudentRepositoryImpl implements StudentRepository {
private static final String KEY = "Student";
private RedisTemplate<String, Student> redisTemplate;
private RedisTemplate<String, Object> redisTemplate;
public void setRedisTemplate(RedisTemplate<String, Student> redisTemplate) {
public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}