<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.8.1.RELEASE</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.6.7</version> </dependency>
applicationContext.xml 에서 아래내용을 확인
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="127.0.0.1" /> <property name="port" value="6379" /> <property name="usePool" value="true" /> </bean> <bean id="redisDao" class="com.poscoict.glueframework.dao.redis.GlueRedisDao"> <property name="connectionFactory" ref="jedisConnectionFactory" /> </bean> <bean id="redisDaoJson" class="com.poscoict.glueframework.dao.redis.GlueRedisDao"> <property name="connectionFactory" ref="jedisConnectionFactory" /> <property name="keySerializer" ref="stringRedisSerializer" /> <property name="valueSerializer"> <bean id="redisJsonSerializer" class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer" /> </property> </bean> <bean id="redisDaoCustom" class="com.poscoict.glueframework.dao.redis.GlueRedisDao"> <property name="connectionFactory" ref="jedisConnectionFactory" /> <property name="keySerializer" ref="stringRedisSerializer" /> <property name="valueSerializer"> <bean id="customSerializer" class="sample.redis.GlueRedisSerializer" /> </property> </bean>
dao 생성시,
serializer property 가 존재하면 해당 serializer 를 GlueRedisDao 에서 RedisTemplate 생성시 DefaultSerializer 로 이용.
serializer 없이 keySerializer 나 valueSerializer 를 전달하면 해당 serializer 를 이용.