redis跟spring结合

快来打我* 2022-06-02 03:28 330阅读 0赞

主要是以下配置文件,里面需要添加的redis.properties等这些文件,根据配置自己添加

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" 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">
  3. <context:property-placeholder location="classpath:redis.properties" />
  4. <context:component-scan base-package="com.x.redis.dao">
  5. </context:component-scan>
  6. <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
  7. <property name="maxIdle" value="${redis.maxIdle}" />
  8. <property name="maxTotal" value="${redis.maxActive}" />
  9. <property name="maxWaitMillis" value="${redis.maxWait}" />
  10. <property name="testOnBorrow" value="${redis.testOnBorrow}" />
  11. </bean>
  12. <bean id="hostport1" class="redis.clients.jedis.HostAndPort">
  13. <constructor-arg name="host" value="10.16.68.92" />
  14. <constructor-arg name="port" value="7770" />
  15. </bean>
  16. <bean id="hostport2" class="redis.clients.jedis.HostAndPort">
  17. <constructor-arg name="host" value="10.16.68.92" />
  18. <constructor-arg name="port" value="7771" />
  19. </bean>
  20. <bean id="hostport3" class="redis.clients.jedis.HostAndPort">
  21. <constructor-arg name="host" value="10.16.68.92" />
  22. <constructor-arg name="port" value="7772" />
  23. </bean>
  24. <bean id="hostport4" class="redis.clients.jedis.HostAndPort">
  25. <constructor-arg name="host" value="10.16.68.92" />
  26. <constructor-arg name="port" value="7773" />
  27. </bean>
  28. <bean id="hostport5" class="redis.clients.jedis.HostAndPort">
  29. <constructor-arg name="host" value="10.16.68.92" />
  30. <constructor-arg name="port" value="7774" />
  31. </bean>
  32. <bean id="hostport6" class="redis.clients.jedis.HostAndPort">
  33. <constructor-arg name="host" value="10.16.68.92" />
  34. <constructor-arg name="port" value="7775" />
  35. </bean>
  36. <bean id="redisCluster" class="redis.clients.jedis.JedisCluster">
  37. <constructor-arg name="nodes">
  38. <set>
  39. <ref bean="hostport1" />
  40. <ref bean="hostport2" />
  41. <ref bean="hostport3" />
  42. <ref bean="hostport4" />
  43. <ref bean="hostport5" />
  44. <ref bean="hostport6" />
  45. </set>
  46. </constructor-arg>
  47. <constructor-arg name="timeout" value="6000" />
  48. <constructor-arg name="poolConfig">
  49. <ref bean="jedisPoolConfig" />
  50. </constructor-arg>
  51. </bean>
  52. </beans>

发表评论

表情:
评论列表 (有 0 条评论,330人围观)

还没有评论,来说两句吧...

相关阅读

    相关 redis结合spring的事务使用

    最近有一个需求,一个接口需要去包另外的3个接口,接口之间的数据相互联系相互依赖,如果有一个接口发生异常或者在主逻辑之中发生异常,那么所有此次产生的数据变化都需要回滚。 \--