<?xml version="1.0" encoding="UTF-8"?>
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:redis="http://www.springframework.org/schema/redis" xmlns:cache="http://www.springframework.org/schema/cache"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:schemaLocation="
|
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context.xsd
|
http://www.springframework.org/schema/aop
|
http://www.springframework.org/schema/aop/spring-aop.xsd
|
http://www.springframework.org/schema/redis
|
http://www.springframework.org/schema/redis/spring-redis.xsd
|
http://www.springframework.org/schema/cache
|
http://www.springframework.org/schema/cache/spring-cache.xsd
|
">
|
<!-- <context:property-placeholder order="1" location="classpath:redis.properties" ignore-unresolvable="true"/> -->
|
<!-- Redis -->
|
<!-- 连接池参数 -->
|
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
|
<property name="maxIdle" value="${redis.pool.maxIdle}" />
|
<property name="minIdle" value="${redis.pool.minIdle}" />
|
<property name="maxTotal" value="${redis.pool.maxTotal}" />
|
<property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}" />
|
<property name="minEvictableIdleTimeMillis" value="${redis.pool.minEvictableIdleTimeMillis}"></property>
|
<property name="numTestsPerEvictionRun" value="${redis.pool.numTestsPerEvictionRun}"></property>
|
<property name="timeBetweenEvictionRunsMillis" value="${redis.pool.timeBetweenEvictionRunsMillis}"></property>
|
<property name="testOnBorrow" value="${redis.pool.testOnBorrow}" />
|
<property name="testOnReturn" value="${redis.pool.testOnReturn}" />
|
<property name="testWhileIdle" value="${redis.pool.testWhileIdle}"></property>
|
</bean>
|
|
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
|
<property name="poolConfig" ref="jedisPoolConfig" />
|
<property name="hostName" value="${redis.host}" />
|
<property name="port" value="${redis.port}" />
|
<property name="password" value="${redis.pwd}" />
|
<property name="usePool" value="${redis.userPool} " />
|
<property name="database" value="${redis.database}" />
|
<property name="timeout" value="${redis.timeout}" />
|
</bean>
|
|
<!-- 配置redis redisTemplate -->
|
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
|
<property name="connectionFactory" ref="jedisConnectionFactory" />
|
<property name="keySerializer">
|
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
</property>
|
<property name="valueSerializer">
|
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
</property>
|
<property name="hashKeySerializer">
|
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
</property>
|
<property name="hashValueSerializer">
|
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
</property>
|
<!-- 开启REIDS事务支持 -->
|
<property name="enableTransactionSupport" value="false" />
|
</bean>
|
|
|
<!-- 对string操作的封装 -->
|
<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
|
<constructor-arg ref="jedisConnectionFactory" />
|
<!-- 开启REIDS事务支持 -->
|
<property name="enableTransactionSupport" value="false" />
|
</bean>
|
|
|
|
</beans>
|