1, 开启缓存注解
<cache:annotation-driven cache-manager="cacheManager"></cache:annotation-driven>
2,开启aop配置
<aop:aspectj-autoproxy/>
3,实现可序列化
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="keySerializer" ref="strKeySerializer">
</property>
<property name="valueSerializer" ref="jdkSerializer">
</property>
<property name="hashKeySerializer" ref="strKeySerializer"></property>
<property name="hashValueSerializer" ref="jdkSerializer"></property>
</bean>
<!-- 字符串序列化 -->
<bean id="strKeySerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<!-- jdk自带writeobject序列化 -->
<bean id="jdkSerializer" class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>