Skip to content

Instantly share code, notes, and snippets.

@tsungtwu
Created June 24, 2018 07:42
Show Gist options
  • Save tsungtwu/7a1e10ccf11aa7b3da9c647d173c9d5b to your computer and use it in GitHub Desktop.
Save tsungtwu/7a1e10ccf11aa7b3da9c647d173c9d5b to your computer and use it in GitHub Desktop.
spring xml configuration for redis
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
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/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="200" />
<property name="maxIdle" value="50" />
<property name="maxWaitMillis" value="3000" />
<property name="testOnBorrow" value="true" />
</bean>
<bean id="jedisFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${redis_ip}" />
<property name="port" value="${redis_port}" />
<property name="poolConfig" ref="jedisPoolConfig" />
<property name="usePool" value="true" />
<!--<property name="password" value="${redis.password}" />-->
<!--<property name="timeout" value="${redis.timeout}" />-->
</bean>
<bean id="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer" />
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="jedisFactory" p:valueSerializer-ref="stringRedisSerializer" p:keySerializer-ref="stringRedisSerializer" />
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment