为了尝试为现有应用程序外部化 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>
Run Code Online (Sandbox Code Playgroud)
在 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>
Run Code Online (Sandbox Code Playgroud)
并在 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}"/>
Run Code Online (Sandbox Code Playgroud)
并构建并部署到 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
Run Code Online (Sandbox Code Playgroud)
任何建议或帮助将不胜感激。谢谢 !!还附上我的 pom.xml 条目: pom.xml 条目