Spring Redis Key garbled

Source: Internet
Author: User
Tags redis serialization tomcat
<bean id= "Stringredisserializer" class= "Org.springframework.data.redis.serializer.StringRedisSerializer"/>  
   
	<bean id= "stringredistemplate" class= "Org.springframework.data.redis.core.StringRedisTemplate"   
		    p: connectionfactory-ref= "Redisconnectionfactory"/> 
    <!--Redis Template---
    <bean id= " 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 = "Stringredisserializer"/>
    </bean>


As on the configuration, you can do it.


------------------------------------------------------------------------------



Follow the configuration below

<bean id= "Redistemplate" class= "Org.springframework.data.redis.core.RedisTemplate"
p:connectionfactory-ref= "Redisconnectionfactory"
p:keyserializer-ref= "Stringredisserializer"
p:hashkeyserializer-ref= "Stringredisserializer"/>


will also be an error

2017.07.21 15:43:18 Com.bimatrix.revit.controller.common.genericcontroller-cannot Deserialize; Nested exception is org.springframework.core.serializer.support.SerializationFailedException:Failed to deserialize Payload. is the byte array a result of corresponding serialization for Defaultdeserializer?;
Nested exception is Java.io.StreamCorruptedException:invalid stream header:77616e67 Org.springframework.data.redis.serializer.SerializationException:Cannot deserialize; Nested exception is org.springframework.core.serializer.support.SerializationFailedException:Failed to deserialize Payload. is the byte array a result of corresponding serialization for Defaultdeserializer?; Nested exception is Java.io.StreamCorruptedException:invalid stream header:77616e67 at Org.springframework.data.redis . Serializer. Jdkserializationredisserializer.deserialize (jdkserializationredisserializer.java:41) at Org.springframework.data.redis.core.AbstractOperations.deserializeHashValue (Abstractoperations.java:296) at Org.springframework.data.redis.core.AbstractOperations.deserializeHashMap ( abstractoperations.java:257) at Org.springframework.data.redis.core.DefaultHashOperations.entries ( defaulthashoperations.java:227) at Org.springframework.data.redis.core.DefaultBoundHashOperations.entries ( defaultboundhashoperations.java:101) at Com.bimatrix.revit.cache.CacheUtils.mget (cacheutils.java:378) at COM.BIMATRIX.REVIT.CONTROLLER.SEAFDATACONTROLLER.TESTREDIS0 (seafdatacontroller.java:112) at SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:57) at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (method.java:606) at Org.springframework.web.method.support.InvocableHandlerMethod.invoke (invocablehandlermethod.java:213) at Org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest (invocablehandlermethod.java:1) at Org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle ( servletinvocablehandlermethod.java:96) at Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod ( requestmappinghandleradapter.java:617) at Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal ( requestmappinghandleradapter.java:578) at Org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle ( ABSTRACTHANDLERMETHODADAPTER.JAVA:80) at Org.springframework.web.servlet.DispatcherServlet.doDispatch ( dispatcherservlet.java:923) at Org.springframework.web.servlet.DispatcherServlet.doService ( dispatcherservlet.java:852) at Org.springframework.web.servlet.FrameworkServlet.processRequest (
	frameworkservlet.java:882) at Org.springframework.web.servlet.FrameworkServlet.doGet (frameworkservlet.java:778) At Javax.servlet.http.HttpServlet.service (httpservlet.java:620) at Javax.servLet.http.HttpServlet.service (httpservlet.java:727) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:303) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:208) at Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:241) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:208) at
	Net.jlrnt.web.ChainModule.forward (chainmodule.java:51) at Net.jlrnt.web.ChainModule.forward (chainmodule.java:54) At Net.jlrnt.web.ChainModule.forward (chainmodule.java:54) at Net.jlrnt.web.ChainModule.forward (Chainmodule.java : Si) at Net.jlrnt.web.FilterController.doFilter (filtercontroller.java:75) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:241) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:208) at Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal ( characterencodingfilter.java:88) at Org.springframework.web.filter.OncePerRequestFilter.doFilter ( onceperrequestfilter.java:76) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter ( applicationfilterchain.java:241) at Org.apache.catalina.core.ApplicationFilterChain.doFilter ( applicationfilterchain.java:208) at Com.bimatrix.revit.filter.IdentifyVerifyFilter.doFilter ( identifyverifyfilter.java:56) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter ( applicationfilterchain.java:241) at Org.apache.catalina.core.ApplicationFilterChain.doFilter ( applicationfilterchain.java:208) at Org.apache.catalina.core.StandardWrapperValve.invoke ( standardwrappervalve.java:220) at Org.apache.catalina.core.StandardContextValve.invoke (Standardcontextvalve.java : 122) at Org.apache.catalina.authenticator.AuthenticatorBase.invoke (authenticatorbase.java:501) at Org.apache.catalina.corE.standardhostvalve.invoke (standardhostvalve.java:170) at Org.apache.catalina.valves.ErrorReportValve.invoke ( errorreportvalve.java:98) at Org.apache.catalina.valves.AccessLogValve.invoke (accesslogvalve.java:950) at Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:116) at Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:408) at Org.apache.coyote.http11.AbstractHttp11Processor.process (abstracthttp11processor.java:1040) at Org.apache.coyote.abstractprotocol$abstractconnectionhandler.process (abstractprotocol.java:607) at Org.apache.tomcat.util.net.jioendpoint$socketprocessor.run (jioendpoint.java:313) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) at Java.lang.Thread.run ( thread.java:745) caused By:org.springframework.core.serializer.support.SerializationFailedException:Failed to Deserialize payload. is the byte aRray a result of corresponding serialization for Defaultdeserializer?; Nested exception is Java.io.StreamCorruptedException:invalid stream header:77616e67 at Org.springframework.core.serializer.support.DeserializingConverter.convert (deserializingconverter.java:61) at Org.springframework.core.serializer.support.DeserializingConverter.convert (deserializingconverter.java:1) at Org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize ( jdkserializationredisserializer.java:39) ... caused By:java.io.StreamCorruptedException:invalid stream header:77616e67 at java.io.ObjectInputStream.readSt Reamheader (objectinputstream.java:804) at java.io.objectinputstream.<init> (objectinputstream.java:299) at Org.springframework.core.serializer.DefaultDeserializer.deserialize (defaultdeserializer.java:38) at Org.springframework.core.serializer.support.DeserializingConverter.convert (deserializingconverter.java:58) ...
 More


Reference http://www.zhaochenxi.com/2015/12/22/spring-redis-key%E4%B9%B1%E7%A0%81/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.