The first figure, the use of the Redistemplate interface to call the data to find the result is empty, this is strange, the data written in the visual software to find out is this:
Classpathxmlapplicationcontext classpathxmlapplicationcontext = new Classpathxmlapplicationcontext ("classpath*: Applicationcontext-redis2.xml ");
Redistemplate = (redistemplate) classpathxmlapplicationcontext.getbean ("Redistemplate");
public void Testgeopos () {
zsetoperations<string, string> zsetoperations = Redistemplate.opsforzset ();
Set set = Zsetoperations.range ("Beijing", 0,zsetoperations.size ("Beijing"));
System.out.print (Set.tostring ()); zsetoperations.add ("Beijing", "hehe", 1);
geooperations<string, string> geooperations = Redistemplate.opsforgeo ();
list<point> list = Redistemplate.opsforgeo (). Geopos ("Beijing", "Dongcheng");
System.out.println (List.tostring ());
}
Use the terminal login to find that the data is really created, but the name of the front more garbled
The solution, Baidu later found that the data transmitted through the network must be serialized after the use of the reason can be Baidu, there are two ways to solve:
1, in the code will be redistemplate serialization;
2. The spring schema can configure serialization in XML.
Redistemplate.setkeyserializer (Stringserializer);
Redistemplate.setvalueserializer (Stringserializer);
Redistemplate.sethashkeyserializer (Stringserializer);
Redistemplate.sethashvalueserializer (Stringserializer);
<bean id= "Redistemplate" name= "Redistemplate" class= "Org.springframework.data.redis.core.RedisTemplate" >
<property name= "ConnectionFactory" ref= "redisconnectionfactory"/> <property name=
"KeySerializer" "ref=" Stringredisserializer "/>
<property name=
" ValueSerializer "ref=" Stringredisserializer "/>" <property name= "Hashkeyserializer" ref= "Stringredisserializer"/> <property name=
"HashValueSerializer" "ref=" Jackson2jsonredisserializer "/>
<!--<property name=" Enabletransactionsupport "value=" true "/ >-->
</bean>
<bean id= "Stringredisserializer"
class= "Org.springframework.data.redis.serializer.StringRedisSerializer" />
You can read it correctly after you modify it.