我在Spring项目中启用了RedisHttpSession使用注释,如下所示
@EnableRedisHttpSession
public class HttpSessionConfig {
...
}
没有启用Http Session Spring社交代码工作正常,从这里参考
https://github.com/spring-projects/spring-social-samples/tree/master/spring-social-showcase
当我启用Redis时,它会出现以下错误:
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: org.springframework.social.connect.support.ConnectionFactoryRegistry
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:67) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:34) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:50) ~[spring-data-redis-1.4.2.RELEASE.jar:1.4.2.RELEASE]
... 36 common frames omitted
Caused by: java.io.NotSerializableException: org.springframework.social.connect.support.ConnectionFactoryRegistry
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183) ~[na:1.7.0_71]
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[na:1.7.0_71]
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508) ~[na:1.7.0_71]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[na:1.7.0_71]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[na:1.7.0_71]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[na:1.7.0_71]
at org.springframework.core.serializer.DefaultSerializer.serialize(DefaultSerializer.java:44) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:62) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
... 38 common frames omitted
任何人都可以帮助我在这里做错了我是redis的新手我错过了一些配置吗?
答案 0 :(得分:0)
基本上,当您访问Redis或任何其他进程外会话提供程序时,您在会话中放置的所有对象都应该是可序列化的。
这就是你的错误实际上说的,你有一些无法序列化的类型。所以你必须找到那种类型
当你发现它可能需要用一些序列化属性来标记它时,或者你可能会发现它是一种根本无法序列化的类型(如Object),并且由于你需要使用其他东西,它会变得更加复杂。
答案 1 :(得分:0)
确保您运行Spring Social 1.1.2+!