1. Software Environment Springmvc4.1.1.release+redis Server (2.8.19)
2. Add redis.clients based on MAVEN support (latest 2.6.2)
<!--redis-->
<dependency>
<groupid>redis.clients</groupId>
<artifactid>jedis</artifactId>
<version>2.6.2</version>
</dependency>
< Span style= "color: #e8bf6a;" > <!- -Spring-redis-->
<dependency>
< Groupid>org.springframework.data</GROUPID>
<artifactid>spring-data-redis</artifactid
<version>1.2.1.release</version
</dependency>
3. New Redis configuration file redis.properties
#redis setting
#ip
Redis.ip=127.0.0.1
#port
Redis.port=6379
#密码
Redis.pass= myredis123
#最大能够保持idel状态的对象数
Redis.maxidle=200
#最大分配的对象数
redis.maxtotal =512
#当池内没有返回对象时, Maximum wait time
Redis.maxwaitmillis=1000
#当调用borrow the object method, check for validity
=true
4. Integrate Redis Spring-redis.xml in the spring configuration file
<!--redis resource file--
<Context:p Roperty-placeholderLocation= "Classpath:redis.properties"/>
<beanId= "Poolconfig"Class= "Redis.clients.jedis.JedisPoolConfig">
<propertyName= "Maxidle"Value= "${redis.maxidle}"/>
<propertyName= "Maxtotal"Value= "${redis.maxtotal}"/>
<propertyName= "Maxwaitmillis"Value= "${redis.maxwaitmillis}"/>
<propertyName= "Testonborrow"Value= "${redis.testonborrow}"/>
</bean>
<beanId= "ConnectionFactory"Class= "Org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<propertyName= "HostName"Value= "${redis.ip}"/>
<propertyName= "Port"Value= "${redis.port}"/>
<propertyName= "Password"Value= "${redis.pass}"/>
<property name= " Poolconfig "value=" Poolconfig " />
</BEAN>
<bean id= " Redistemplate "class=" Org.springframework.data.redis.core.StringRedisTemplate ">
<property name= "ConnectionFactory" ref= "ConnectionFactory" />
</bean>
SPRINGMVC Integrated Redis