redis.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
  3. xsi:schemaLocation="http://www.springframework.org/schema/beans
  4. http://www.springframework.org/schema/beans/spring-beans.xsd
  5. http://www.springframework.org/schema/context
  6. http://www.springframework.org/schema/context/spring-context-3.2.xsd">
  7. <!-- <context:property-placeholder location="classpath:redis.properties"/> -->
  8. <bean id="propertyConfigurerRedis" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  9. <property name="order" value="1"/>
  10. <property name="ignoreUnresolvablePlaceholders" value="true"/>
  11. <property name="systemPropertiesMode" value="1"/>
  12. <property name="searchSystemEnvironment" value="true"/>
  13. <property name="locations">
  14. <list>
  15. <value>classpath:redis.properties</value>
  16. </list>
  17. </property>
  18. </bean>
  19. <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
  20. <property name="maxIdle" value="${redis.maxIdle}"/>
  21. <property name="testOnBorrow" value="${redis.testOnBorrow}"/>
  22. </bean>
  23. <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
  24. <property name="usePool" value="true"></property>
  25. <property name="hostName" value="${redis.host}"/>
  26. <property name="port" value="${redis.port}"/>
  27. <property name="password" value="${redis.password}"/>
  28. <property name="timeout" value="${redis.timeout}"/>
  29. <property name="database" value="${redis.default.db}"/>
  30. <constructor-arg index="0" ref="jedisPoolConfig"/>
  31. </bean>
  32. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
  33. p:connectionFactory-ref="jedisConnectionFactory"/>
  34. <bean id="redisBase" abstract="true">
  35. <property name="template" ref="redisTemplate"/>
  36. </bean>
  37. <context:component-scan base-package="com.whzl.oaweb.redis">
  38. <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
  39. </context:component-scan>
  40. </beans>