1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"
- default-lazy-init="true">
- <description>Jedis Configuration</description>
- <!-- 加载配置属性文件 -->
- <context:property-placeholder ignore-unresolvable="true" location="classpath:caimei.properties" />
- <!-- spring data redis -->
- <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
- <property name="usePool" value="true"></property>
- <property name="hostName" value="${redis.host}" />
- <property name="port" value="${redis.port}" />
- <property name="password" value="#{'${redis.pass}'!='123456'?'${redis.pass}':null}" />
- <property name="timeout" value="${redis.timeout}" />
- <property name="database" value="0"></property>
- <constructor-arg index="0" ref="jedisPoolConfig" />
- </bean>
- <!-- jedis pool配置 -->
- <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
- <property name="maxTotal" value="${redis.pool.maxTotal}"/>
- <property name="maxIdle" value="${redis.pool.maxIdle}"/>
- <property name="minIdle" value="${redis.pool.minIdle}"/>
- <property name="maxWaitMillis" value="${redis.pool.maxWait}"/>
- <property name="testOnBorrow" value="true"/>
- <property name="testOnReturn" value="false"/>
- <property name="testWhileIdle" value="false"/>
- <!-- <property name="testOnBorrow" value="${redis.testOnBorrow}" /> -->
- </bean>
- <!-- Redis Template -->
- <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
- <property name="connectionFactory" ref="jedisConnectionFactory" />
- <property name="keySerializer">
- <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
- </property>
- <property name="hashKeySerializer">
- <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
- </property>
- <property name="valueSerializer">
- <bean class="com.caimei.redis.GenericJackson2JsonRedisSerializer"/>
- </property>
- <property name="hashValueSerializer">
- <bean class="com.caimei.redis.GenericJackson2JsonRedisSerializer"/>
- </property>
- </bean>
- <!--<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
- <property name="maxActive" value="${redis.pool.maxActive}" /><!–最大连接数–>
- <property name="maxIdle" value="${redis.pool.maxIdle}" /> <!–最大空闲连接数,即 最大能够保持idel状态的对象数 –>
- <property name="minIdle" value="${redis.pool.minIdle}"/><!–初始化连接数–>
- <property name="maxWait" value="${redis.pool.maxWait}" /> <!–最大等待时间–>
- <property name="maxTotal" value="${redis.pool.maxTotal}" /> <!– 最大分配的对象数 –>
- <property name="testOnBorrow" value="true" /> <!– 当调用borrow Object方法时,是否进行有效性检查 –>
- </bean>
- <bean id="jedisPool" class="redis.clients.jedis.JedisPool">
- <constructor-arg index="0" ref="jedisPoolConfig" />
- <constructor-arg index="1" value="${redis.host}" />
- <constructor-arg index="2" value="${redis.port}" type="int" />
- <!–timeout–>
- <constructor-arg index="3" value="${redis.timeout}"/>
- <constructor-arg index="4" value="${${redis.password}}"/>
- </bean>-->
- </beans>
|