spring-mvc-context.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  7. http://www.springframework.org/schema/context
  8. http://www.springframework.org/schema/context/spring-context-3.0.xsd
  9. http://www.springframework.org/schema/mvc
  10. http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
  11. <!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 -->
  12. <context:component-scan base-package="org.jeecgframework.core.aop" />
  13. <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
  14. <property name="maxIdle" value="${redis.maxIdle}" />
  15. <property name="maxTotal" value="${redis.maxActive}" />
  16. <property name="maxWaitMillis" value="${redis.maxWait}" />
  17. <property name="testOnBorrow" value="${redis.testOnBorrow}" />
  18. </bean>
  19. <!-- redis单机环境配置开始 -->
  20. <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
  21. p:hostName="${redis.host}" p:port="${redis.port}" p:password="${redis.pass}" p:poolConfig-ref="poolConfig"/>
  22. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
  23. <property name="connectionFactory" ref="connectionFactory" />
  24. <property name="keySerializer">
  25. <bean
  26. class="org.springframework.data.redis.serializer.StringRedisSerializer" />
  27. </property>
  28. <property name="valueSerializer">
  29. <bean
  30. class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
  31. </property>
  32. <property name="hashKeySerializer">
  33. <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
  34. </property>
  35. </bean>
  36. <!-- redis单机环境配置结束 -->
  37. <!-- redis集群环境配置开始 -->
  38. <!-- <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:use-pool="true">
  39. <constructor-arg ref="redisClusterConfiguration" />
  40. <constructor-arg ref="poolConfig" />
  41. </bean>
  42. <bean id="clusterRedisNodes1" class="org.springframework.data.redis.connection.RedisNode">
  43. <constructor-arg value="192.168.200.5" />
  44. <constructor-arg value="6479" type="int" />
  45. </bean>
  46. <bean id="clusterRedisNodes2" class="org.springframework.data.redis.connection.RedisNode">
  47. <constructor-arg value="192.168.200.6" />
  48. <constructor-arg value="7003" type="int" />
  49. </bean>
  50. <bean id="clusterRedisNodes3" class="org.springframework.data.redis.connection.RedisNode">
  51. <constructor-arg value="192.168.200.6" />
  52. <constructor-arg value="7004" type="int" />
  53. </bean>
  54. <bean id="redisClusterConfiguration" class="org.springframework.data.redis.connection.RedisClusterConfiguration">
  55. <property name="clusterNodes">
  56. <set>
  57. <ref bean="clusterRedisNodes1"/>
  58. <ref bean="clusterRedisNodes2"/>
  59. <ref bean="clusterRedisNodes3"/>
  60. </set>
  61. </property>
  62. </bean>
  63. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
  64. <property name="connectionFactory" ref="jedisConnFactory" />
  65. <property name="keySerializer">
  66. <bean
  67. class="org.springframework.data.redis.serializer.StringRedisSerializer" />
  68. </property>
  69. <property name="valueSerializer">
  70. <bean
  71. class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
  72. </property>
  73. </bean> -->
  74. <!-- redis集群环境配置结束 -->
  75. </beans>