【发布时间】:2016-11-26 17:30:53
【问题描述】:
为了为我现有的应用程序外部化 tomcat 会话,我正在尝试 Spring Session Redis 解决方案。按照以下步骤在 pom.xml 中包含必要的依赖项后:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
像这样在 web.xml 中添加 springSessionRepositoryFilter :
<filter>
<filter-name>springSessionRepositoryFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSessionRepositoryFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
并在 Spring XML 配置中添加以下内容
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>
<context:property-placeholder location="classpath:application.properties"/>
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:port="${spring.redis.port}"/>
在 tomcat 上构建和部署,这是我得到的错误:
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.sun.jersey.client.apache.ApacheHttpClient
非常感谢任何建议或帮助。谢谢 !! 还附上了我的 pom.xml 条目: pom.xml entries
【问题讨论】:
-
你能发布异常的完整堆栈跟踪吗?
-
java.io.NotSerializableException我猜你试图保存为会话状态的任何对象都是不可序列化的。发布有关保存会话状态的机制的更多详细信息
标签: spring tomcat redis spring-session