cache-redis.xml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c"
  4. xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:cache="http://www.springframework.org/schema/cache"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  8. http://www.springframework.org/schema/context
  9. http://www.springframework.org/schema/context/spring-context-4.0.xsd
  10. http://www.springframework.org/schema/cache
  11. http://www.springframework.org/schema/cache/spring-cache-4.0.xsd"
  12. default-autowire="byName">
  13. <cache:annotation-driven cache-manager="cacheManager" />
  14. <context:component-scan base-package="com.uas" />
  15. <!-- redis 相关配置 -->
  16. <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
  17. <property name="maxIdle" value="300" />
  18. <property name="maxWaitMillis" value="3000" />
  19. <property name="testOnBorrow" value="true" />
  20. </bean>
  21. <bean id="connectionFactory"
  22. class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
  23. p:host-name="192.168.253.111" p:port="6379" p:pool-config-ref="poolConfig"
  24. p:database="0" />
  25. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
  26. <property name="connectionFactory" ref="connectionFactory" />
  27. </bean>
  28. <bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager"
  29. c:redis-operations-ref="redisTemplate" />
  30. </beans>