1. The integrated configuration file is as follows<!--Spring Integrated Redis - <BeanID= "Poolconfig"class= "Redis.clients.jedis.JedisPoolConfig"> < Propertyname= "Maxtotal"value= "+"/> </Bean> <!--Configuring Jedisconnectionfactorybean Objects - <BeanID= "Jedisconnectionfactory"class= "Org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> < Propertyname= "HostName"value= "localhost"/> < Propertyname= "Port"value= "6379"/> < Propertyname= "Poolconfig"ref= "Poolconfig"/> </Bean> <!--Configure Redistemplate - <BeanID= "Redistemplate"class= "Org.springframework.data.redis.core.RedisTemplate"> < Propertyname= "ConnectionFactory"ref= "Jedisconnectionfactory"/> < Propertyname= "Keyserializer"> <Beanclass= "Org.springframework.data.redis.serializer.StringRedisSerializer"/> </ Property> < Propertyname= "ValueSerializer"> <Beanclass= "Org.springframework.data.redis.serializer.StringRedisSerializer"/> </ Property> </Bean>2. The test code is as follows @Test public void Run7 () throws exception{applicationcontext ac = new Classpathxmlapplicationc Ontext ("Classpath:applicationcontext-redis.xml"); Redistemplate<String, String>t = (redistemplate<String, String>) Ac.getbean ("Redistemplate"); T.opsforvalue (). Set ("msg", "haha"); }
Spring Data JPA consolidates the configuration of the Redis cache