背景:本MUEAS项目,一开始的时候,是没有引入redis的,考虑到后期性能的问题而引入。之前没有引用redis的时候,用户登录是正常的。但是,在加入redis支持后,登录就出错!错误如下:

   .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.7.RELEASE) [-- ::37.165] log4j - INFO [main] --- Application: Starting Application on CloudGame with PID (/home/webWps/mueas-mongo/target/classes started by root in /home/webWps/mueas-mongo)
[-- ::37.237] log4j - INFO [main] --- AnnotationConfigEmbeddedWebApplicationContext: Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7c271d34: startup date [Tue Dec :: CST ]; root of context hierarchy
[-- ::39.868] log4j - INFO [main] --- AutowiredAnnotationBeanPostProcessor: JSR- 'javax.inject.Inject' annotation found and supported for autowiring
[-- ::40.163] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerBySpringCGLIB$$] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.419] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [class org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$525eef57] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.449] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'objectPostProcessor' of type [class org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.451] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@2cd84149' of type [class org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.476] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'mueasPermissionEvaluator' of type [class com.tinguish.mueas.infra.security.MueasPermissionEvaluator] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.540] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'methodSecurityConfig' of type [class com.tinguish.mueas.infra.security.MethodSecurityConfig$$EnhancerBySpringCGLIB$$5242b1ec] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.557] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'methodSecurityMetadataSource' of type [class org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::40.562] log4j - INFO [main] --- PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'metaDataSourceAdvisor' of type [class org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[-- ::41.039] log4j - INFO [main] --- TomcatEmbeddedServletContainer: Tomcat initialized with port(s): (http)
[-- ::41.449] log4j - INFO [main] --- StandardService: Starting service Tomcat
[-- ::41.451] log4j - INFO [main] --- StandardEngine: Starting Servlet Engine: Apache Tomcat/8.0.
[-- ::41.657] log4j - INFO [localhost-startStop-] --- [/]: Initializing Spring embedded WebApplicationContext
[-- ::41.657] log4j - INFO [localhost-startStop-] --- ContextLoader: Root WebApplicationContext: initialization completed in ms
[-- ::44.031] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: Ant [pattern='/css/**'], []
[-- ::44.031] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: Ant [pattern='/js/**'], []
[-- ::44.031] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: Ant [pattern='/images/**'], []
[-- ::44.031] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: Ant [pattern='/**/favicon.ico'], []
[-- ::44.031] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: Ant [pattern='/error'], []
[-- ::44.138] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@272b811d, org.springframework.security.web.context.SecurityContextPersistenceFilter@1ab55f98, org.springframework.security.web.header.HeaderWriterFilter@7da7fe14, org.springframework.security.web.authentication.logout.LogoutFilter@296758e5, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@55ac5e8a, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@28facd93, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@74f4c543, org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter@, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@1929ab02, org.springframework.security.web.session.SessionManagementFilter@615a1d5f, org.springframework.security.web.access.ExceptionTranslationFilter@1468193e, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@273c59de]
[-- ::44.155] log4j - INFO [localhost-startStop-] --- DefaultSecurityFilterChain: Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5f8f81db, org.springframework.security.web.context.SecurityContextPersistenceFilter@165973f5, org.springframework.security.web.header.HeaderWriterFilter@723a02aa, org.springframework.security.web.authentication.logout.LogoutFilter@60c20fb6, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@6495a75a, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4acbe549, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@103a41fc, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@469681e0, org.springframework.security.web.session.SessionManagementFilter@3e85217c, org.springframework.security.web.access.ExceptionTranslationFilter@45c69c37, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3470e41a]
[-- ::44.471] log4j - INFO [localhost-startStop-] --- FilterRegistrationBean: Mapping filter: 'characterEncodingFilter' to: [/*]
[2015-12-29 10:18:44.471] log4j - 31595 INFO [localhost-startStop-1] --- FilterRegistrationBean: Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
[2015-12-29 10:18:44.472] log4j - 31595 INFO [localhost-startStop-1] --- FilterRegistrationBean: Mapping filter: 'springSessionRepositoryFilter' to: [/*]
[2015-12-29 10:18:44.472] log4j - 31595 INFO [localhost-startStop-1] --- FilterRegistrationBean: Mapping filter: 'springSecurityFilterChain' to: [/*]
[2015-12-29 10:18:44.472] log4j - 31595 INFO [localhost-startStop-1] --- ServletRegistrationBean: Mapping servlet: 'dispatcherServlet' to [/]
[2015-12-29 10:18:44.838] log4j - 31595 INFO [main] --- RequestMappingHandlerAdapter: Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7c271d34: startup date [Tue Dec 29 10:18:37 CST 2015]; root of context hierarchy
[2015-12-29 10:18:44.926] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/userid],methods=[POST]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.userId(com.tinguish.mueas.user.model.User,java.lang.String)
[2015-12-29 10:18:44.926] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/pri_college]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.userPriCollege(com.tinguish.mueas.user.model.User)
[2015-12-29 10:18:44.927] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/sec_college]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.userSecCollege(com.tinguish.mueas.user.model.User)
[2015-12-29 10:18:44.927] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/check/oldPassword]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.checkOldPassword(com.tinguish.mueas.user.model.User,java.lang.String)
[2015-12-29 10:18:44.927] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting]}" onto public org.springframework.web.servlet.ModelAndView com.tinguish.mueas.user.controller.UserController.mySetting(com.tinguish.mueas.user.model.User)
[2015-12-29 10:18:44.927] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/m_single]}" onto public org.springframework.web.servlet.ModelAndView com.tinguish.mueas.user.controller.UserController.createSingleUser()
[2015-12-29 10:18:44.927] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/m_multi]}" onto public org.springframework.web.servlet.ModelAndView com.tinguish.mueas.user.controller.UserController.createMultiUsers()
[2015-12-29 10:18:44.928] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/m_mgmt]}" onto public org.springframework.web.servlet.ModelAndView com.tinguish.mueas.user.controller.UserController.mgmtUsers(com.tinguish.mueas.user.model.User)
[2015-12-29 10:18:44.928] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/new/one]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.createUser(javax.servlet.http.HttpServletRequest)
[2015-12-29 10:18:44.928] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/profile]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.userProfile(com.tinguish.mueas.user.model.User)
[2015-12-29 10:18:44.928] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/username],methods=[POST]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.userName(com.tinguish.mueas.user.model.User,java.lang.String)
[2015-12-29 10:18:44.929] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/user/setting/password]}" onto public java.util.Map<java.lang.String, java.lang.String> com.tinguish.mueas.user.controller.UserController.userPassword(com.tinguish.mueas.user.model.User,java.lang.String,java.lang.String)
[2015-12-29 10:18:44.929] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/ || /home]}" onto public java.lang.String com.tinguish.mueas.infra.login.LoginController.home()
[2015-12-29 10:18:44.930] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/seeu]}" onto public java.lang.String com.tinguish.mueas.infra.login.LoginController.logout()
[2015-12-29 10:18:44.930] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/login]}" onto public org.springframework.web.servlet.ModelAndView com.tinguish.mueas.infra.login.LoginController.login(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
[2015-12-29 10:18:44.931] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/password/forgot],methods=[POST]}" onto public java.lang.String com.tinguish.mueas.infra.password.ForgotPasswordController.forgetPassword(com.tinguish.mueas.user.model.User,org.springframework.ui.Model) throws javax.mail.MessagingException,java.io.IOException
[2015-12-29 10:18:44.931] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/password/forgot],methods=[GET]}" onto public java.lang.String com.tinguish.mueas.infra.password.ForgotPasswordController.resetPasswordView(org.springframework.ui.Model)
[2015-12-29 10:18:44.932] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/password/reset],methods=[GET]}" onto public java.lang.String com.tinguish.mueas.infra.password.ResetPasswordController.resetpasswordView(java.lang.String,org.springframework.ui.Model)
[2015-12-29 10:18:44.932] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/password/reset],methods=[POST]}" onto public java.lang.String com.tinguish.mueas.infra.password.ResetPasswordController.resetPassword(java.lang.String,com.tinguish.mueas.user.model.User,org.springframework.ui.Model)
[2015-12-29 10:18:44.932] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/error]}" onto org.springframework.web.servlet.ModelAndView com.tinguish.mueas.infra.error.MueasErrorController.error(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
[2015-12-29 10:18:44.933] log4j - 31595 INFO [main] --- RequestMappingHandlerMapping: Mapped "{[/mgmt/score/ || /mgmt/score]}" onto public org.springframework.web.servlet.ModelAndView com.tinguish.mueas.score.ScoreMgmtController.Score()
[2015-12-29 10:18:44.992] log4j - 31595 INFO [main] --- SimpleUrlHandlerMapping: Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2015-12-29 10:18:44.993] log4j - 31595 INFO [main] --- SimpleUrlHandlerMapping: Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[2015-12-29 10:18:45.090] log4j - 31595 INFO [main] --- SimpleUrlHandlerMapping: Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
[-- ::45.544] log4j - INFO [main] --- AnnotationMBeanExporter: Registering beans for JMX exposure on startup
[-- ::45.554] log4j - INFO [main] --- DefaultLifecycleProcessor: Starting beans in phase
[-- ::45.757] log4j - INFO [main] --- TomcatEmbeddedServletContainer: Tomcat started on port(s): (http)
[-- ::45.760] log4j - INFO [main] --- Application: Started Application in 8.99 seconds (JVM running for 9.316)
[-- ::41.487] log4j - INFO [http-nio--exec-] --- [/]: Initializing Spring FrameworkServlet 'dispatcherServlet'
[-- ::41.488] log4j - INFO [http-nio--exec-] --- DispatcherServlet: FrameworkServlet 'dispatcherServlet': initialization started
[-- ::41.507] log4j - INFO [http-nio--exec-] --- DispatcherServlet: FrameworkServlet 'dispatcherServlet': initialization completed in ms
[-- ::41.690] log4j - INFO [http-nio--exec-] --- TemplateEngine: [THYMELEAF] INITIALIZING TEMPLATE ENGINE
[-- ::41.765] log4j - INFO [http-nio--exec-] --- AbstractTemplateResolver: [THYMELEAF] INITIALIZING TEMPLATE RESOLVER: org.thymeleaf.templateresolver.TemplateResolver
[-- ::41.765] log4j - INFO [http-nio--exec-] --- AbstractTemplateResolver: [THYMELEAF] TEMPLATE RESOLVER INITIALIZED OK
[-- ::41.766] log4j - INFO [http-nio--exec-] --- AbstractMessageResolver: [THYMELEAF] INITIALIZING MESSAGE RESOLVER: org.thymeleaf.spring4.messageresolver.SpringMessageResolver
[-- ::41.766] log4j - INFO [http-nio--exec-] --- AbstractMessageResolver: [THYMELEAF] MESSAGE RESOLVER INITIALIZED OK
[-- ::41.775] log4j - INFO [http-nio--exec-] --- CONFIG: [THYMELEAF] TEMPLATE ENGINE CONFIGURATION:
[THYMELEAF] * Cache Factory implementation: org.thymeleaf.cache.StandardCacheManager
[THYMELEAF] * Template modes:
[THYMELEAF] * VALIDXML
[THYMELEAF] * HTML5
[THYMELEAF] * VALIDXHTML
[THYMELEAF] * LEGACYHTML5
[THYMELEAF] * XHTML
[THYMELEAF] * XML
[THYMELEAF] * Template resolvers (in order):
[THYMELEAF] * org.thymeleaf.templateresolver.TemplateResolver
[THYMELEAF] * Message resolvers (in order):
[THYMELEAF] * org.thymeleaf.spring4.messageresolver.SpringMessageResolver
[THYMELEAF] * Dialect [ of ]: org.thymeleaf.spring4.dialect.SpringStandardDialect
[THYMELEAF] * Prefix: "th"
[THYMELEAF] * Dialect [ of ]: org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect
[THYMELEAF] * Prefix: "sec"
[THYMELEAF] * Dialect [ of ]: nz.net.ultraq.thymeleaf.LayoutDialect
[THYMELEAF] * Prefix: "layout"
[THYMELEAF] TEMPLATE ENGINE CONFIGURED OK
[-- ::41.775] log4j - INFO [http-nio--exec-] --- TemplateEngine: [THYMELEAF] TEMPLATE ENGINE INITIALIZED
[-- ::50.834] log4j - ERROR [http-nio--exec-] --- [dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: com.tinguish.mueas.user.model.User
at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:)
at org.springframework.data.redis.core.AbstractOperations.rawHashValue(AbstractOperations.java:)
at org.springframework.data.redis.core.DefaultHashOperations.putAll(DefaultHashOperations.java:)
at org.springframework.data.redis.core.DefaultBoundHashOperations.putAll(DefaultBoundHashOperations.java:)
at org.springframework.session.data.redis.RedisOperationsSessionRepository$RedisSession.saveDelta(RedisOperationsSessionRepository.java:)
at org.springframework.session.data.redis.RedisOperationsSessionRepository$RedisSession.access$(RedisOperationsSessionRepository.java:)
at org.springframework.session.data.redis.RedisOperationsSessionRepository.save(RedisOperationsSessionRepository.java:)
at org.springframework.session.data.redis.RedisOperationsSessionRepository.save(RedisOperationsSessionRepository.java:)
at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.commitSession(SessionRepositoryFilter.java:)
at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.access$(SessionRepositoryFilter.java:)
at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:)
at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:)
at java.lang.Thread.run(Thread.java:)
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: com.tinguish.mueas.user.model.User
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:)
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:)
at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:)
... more
Caused by: java.io.NotSerializableException: com.tinguish.mueas.user.model.User
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:)
at org.springframework.core.serializer.DefaultSerializer.serialize(DefaultSerializer.java:)
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:)
... more

很是奇怪。。。。。。

后来拜读了一下spring data redis的官方文档:

From the framework perspective, the data stored in Redis is just bytes. While Redis itself supports various types, for the most part these refer to the way the data is stored rather then what it represents. It is up to the user to decide whether the information gets translated into Strings or any other objects. The conversion between the user (custom) types and raw data (and vice-versa) is handled in Spring Data Redis through the RedisSerializer interface (package org.springframework.data.redis.serializer) which as the name implies, takes care of the serialization process. Multiple implementations are available out of the box, two of which have been already mentioned before in this documentation: the StringRedisSerializer and the JdkSerializationRedisSerializer. However one can use OxmSerializer for Object/XML mapping through Spring 3 OXM support or either JacksonJsonRedisSerializer, Jackson2JsonRedisSerializer or `GenericJackson2JsonRedisSerializer for storing data in JSON format. Do note that the storage format is not limited only to values - it can be used for keys, values or hashes without any restrictions.

从中得到一点启发,那就是spring session redis将session存入到redis后,是将数据序列化后存入的,所以,当没有序列化的数据,直接从数据库读出来,在经过spring security认证之后,会将SecurityContext写入到httpSesson中.

org.springframework.security.web.context.HttpSessionSecurityContextRepository$SaveToSessionResponseWrapper中saveContext的操作,将会把SecurityContext以SPRING_SECURITY_CONTEXT为key写入httpSession中,而SecurityContext中包含了authentication (UsernamePasswordAuthenticationToken),这个,我相信大家都知道了,这个里面就含有当前登录操作的principle,即继承于UserDetails。

出于这个考虑,结合错误提示信息Caused by: java.io.NotSerializableException: com.tinguish.mueas.user.model.User,于是将我的User类,改为下面的形式:

 //注意,我的User继承BasicUser,所以,只将BasicUser继承Serializable。
public class BasicUser implements Serializable{ /**
*
*/
private static final long serialVersionUID = -8366929034564774130L; 。。。。。。。。。。。。。
}

经过上面的简单修改后,果然,可以正常的登录了,不再出现上述错误,一切操作都正常!

正常运行下的redis的session下的内容可以看到:

127.0.0.1:6379> hkeys spring:session:sessions:f5a6f5fa-0d8a-4250-87bd-ca6a82384fe2
1) "sessionAttr:SPRING_SECURITY_SAVED_REQUEST"
2) "sessionAttr:SPRING_SECURITY_CONTEXT"
3) "maxInactiveInterval"
4) "creationTime"
5) "lastAccessedTime"
6) "sessionAttr:SPRING_SECURITY_LAST_EXCEPTION"

Spring boot配合Spring session(redis)遇到的错误的更多相关文章

  1. Spring Boot 多站点利用 Redis 实现 Session 共享

    如何在不同站点(web服务进程)之间共享会话 Session 呢,原理很简单,就是把这个 Session 独立存储在一个地方,所有的站点都从这个地方读取 Session. 通常我们使用 Redis 来 ...

  2. Spring Boot:Spring Boot 中 Redis 的使用

    Redis 介绍 Redis 是目前业界使用最广泛的内存数据存储.相比 Memcached,Redis 支持更丰富的数据结构,例如 hashes, lists, sets 等,同时支持数据持久化.除此 ...

  3. 转 Spring Boot之No session repository could be auto-configured, check your configuration问题解决

    1.  环境介绍 JDK 1.8  Spring-Boot 1.5.1.RELEASE, STS IDE 2.  问题的提出 创建了一个非常简约的Spring Boot Web Application ...

  4. Spring Boot集成Spring Data Reids和Spring Session实现Session共享

    首先,需要先集成Redis的支持,参考:http://www.cnblogs.com/EasonJim/p/7805665.html Spring Boot集成Spring Data Redis+Sp ...

  5. Spring Boot 2.x整合Redis

    最近在学习Spring Boot 2.x整合Redis,在这里和大家分享一下,希望对大家有帮助. Redis是什么 Redis 是开源免费高性能的key-value数据库.有以下的优势(源于Redis ...

  6. Spring boot配置多个Redis数据源操作实例

    原文:https://www.jianshu.com/p/c79b65b253fa Spring boot配置多个Redis数据源操作实例 在SpringBoot是项目中整合了两个Redis的操作实例 ...

  7. 7、Spring Boot 2.x 集成 Redis

    1.7 Spring Boot 2.x 集成 Redis 简介 继续上篇的MyBatis操作,详细介绍在Spring Boot中使用RedisCacheManager作为缓存管理器,集成业务于一体. ...

  8. Spring Boot 2.x 整合 Redis最佳实践

    一.前言 在前面的几篇文章中简单的总结了一下Redis相关的知识.本章主要讲解一下 Spring Boot 2.0 整合 Redis.Jedis 和 Lettuce 是 Java 操作 Redis 的 ...

  9. Spring Boot 如何快速集成 Redis 哨兵?

    上一篇:Spring Boot 如何快速集成 Redis? 前面的分享栈长介绍了如何使用 Spring Boot 快速集成 Redis,上一篇是单机版,也有粉丝留言说有没有 Redis Sentine ...

随机推荐

  1. [转]ELO等级分体系

    [译前注:有读者问ELO等级分体系的说明.观网上好象没发现单篇文章就说得通俗清晰的,只好把找到几篇文章拿在一起合译互相补充.其间发现具体说法稍有差异,但总的来说概念一致.FIDE已经专门制定计算表了, ...

  2. Why does my ListView scroll to the top when navigating backwards?

    I’ve seen a few people asking this question. They have a page which contains a ListView and when an ...

  3. Particles.js基于Canvas画布创建粒子原子颗粒效果

    文章目录 使用方法 自定义参数 相关链接 Particles.js是一款基于HTML5 Canvas画布的轻量级粒子动画插件,可以设置粒子的形状.旋转.分布.颜色等属性,还可以动态添加粒子,效果非常炫 ...

  4. 使用apt-get方式为Kubuntu安装PHP+MYSQL+Apache

    相信很多搭过动态网站的朋友都知道怎么搭web服务器, 本人是linux新手, 以前在windows是直接使用集成的wamp server, 所以在linux没有亲手搭过. 本系统: ubuntu 12 ...

  5. SAP系统联机应用程序帮助

    新安装好的SAP系统,联机帮助是不能用的. 通过菜单中的“帮助-应用程序帮助” 和“帮助-SAP库”都打不开任何帮助页面.这并不是因为SAPgui安装不完整,而是因为SAP的帮助系统本身就不包含在GU ...

  6. 如何让Android字体自适应屏幕分辨率

    在不同的分辨率下,Android字体大小怎么自适应分辨率的变化? 假设需要适应320x240,480x320分辨率.在res目录下新建文件夹values-320x240, values-480x320 ...

  7. 350. Intersection of Two Arrays II

    Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1] ...

  8. AndroidStudio导入Android-PullToRefresh

    方法已经写到我的微信公众号中,公众号二维码在下面 本人联系方式: 更多精彩分享,可关注我的微信公众号: 若想给予我分享更多知识的动力,请扫描下面的微信打赏二维码,谢谢!: 微信号:WeixinJung ...

  9. 转:linux 修改sftp服务默认提供者sshd的session timeout

    ssh连接超时问题解决方案: 1.修改server端的etc/ssh/sshd_config ClientAliveInterval 60 #server每隔60秒发送一次请求给client,然后cl ...

  10. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...