Commit bd35191b by java-李谡

添加redis依赖

parent d58bba2b
redis.host=106.75.105.96 redis.host=106.75.105.96
redis.port=7211 redis.port=7211
redis.auth=bbdtek!@#2018 redis.auth=bbdtek!@#2018
redis.timeout=10000
redis.maxTotal=100 redis.maxTotal=100
redis.maxIdle=20 redis.maxIdle=20
redis.maxWaitMillis=10000 redis.maxWaitMillis=10000
......
...@@ -151,50 +151,11 @@ ...@@ -151,50 +151,11 @@
<property name="testOnBorrow" value="${redis.testOnBorrow}"/> <property name="testOnBorrow" value="${redis.testOnBorrow}"/>
<property name="testOnReturn" value="${redis.testOnReturn}"/> <property name="testOnReturn" value="${redis.testOnReturn}"/>
</bean> </bean>
<!--redis链接密码--> <bean id="jedisPool" class="redis.clients.jedis.JedisPool">
<bean id="redisPassword" class="org.springframework.data.redis.connection.RedisPassword"> <constructor-arg name="poolConfig" ref="jedisPoolConfig"/>
<constructor-arg name="thePassword" value="${redis.auth}"></constructor-arg> <constructor-arg name="host" value="${redis.host}"/>
</bean> <constructor-arg name="port" value="${redis.port}"/>
<constructor-arg name="timeout" value="${redis.timeout}"/>
<!--spring-data-redis2.0以上的配置--> <constructor-arg name="password" value="${redis.auth}"/>
<bean id="redisStandaloneConfiguration"
class="org.springframework.data.redis.connection.RedisStandaloneConfiguration">
<property name="hostName" value="${redis.host}"/>
<property name="port" value="${redis.port}"/>
<property name="password" ref="redisPassword"/>
<property name="database" value="${redis.dbIndex}"/>
</bean>
<!--配置jedis链接工厂 spring-data-redis2.0中
建议改为构造器传入一个RedisStandaloneConfiguration 单机
RedisSentinelConfiguration 主从复制
RedisClusterConfiguration 集群-->
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<!--spring-data-redis2.0以上建议获取的方式-->
<constructor-arg name="standaloneConfig" ref="redisStandaloneConfiguration"></constructor-arg>
</bean>
<!--手动设置 key 与 value的序列化方式-->
<bean id="keySerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<bean id="valueSerializer" class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
<!--配置jedis模板 -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"/>
<property name="keySerializer" ref="keySerializer"/>
<property name="valueSerializer" ref="valueSerializer"/>
<property name="hashKeySerializer" ref="keySerializer"/>
<property name="hashValueSerializer" ref="valueSerializer"/>
</bean>
<!--也可以StringRedisTemplate 专注于String的操作 -->
<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<!--<property name="connectionFactory" ref="jedisConnectionFactory"></property>-->
<!--在StringRedisTemplate与redisTemplate不同,可以直接造构造器中传入ConnectionFactory-->
<constructor-arg name="connectionFactory" ref="jedisConnectionFactory"></constructor-arg>
<property name="keySerializer" ref="keySerializer"/>
<property name="valueSerializer" ref="valueSerializer"/>
<property name="hashKeySerializer" ref="keySerializer"/>
<property name="hashValueSerializer" ref="valueSerializer"/>
</bean> </bean>
</beans> </beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment