spring session redis'没有定义名为'springSessionRepositoryFilter'的bean' [英] spring session redis 'No bean named 'springSessionRepositoryFilter' is defined'

查看:105
本文介绍了spring session redis'没有定义名为'springSessionRepositoryFilter'的bean'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JDK1.7
Tomcat8
Redis SV 3.0
spring3.2.14、jedis 2.8.1、spring session 1.2、spring data redis 1.7

JDK1.7
Tomcat8
Redis sv 3.0
Spring3.2.14, jedis 2.8.1, spring session 1.2, spring data redis 1.7

[INFO ][XmlBeanDefinitionReader(loadBeanDefinitions:316)] Loading XML bean definitions 
[INFO ][DefaultListableBeanFactory(preInstantiateSingletons:603)] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@66039e85: defining beans [redisHttpSessionConfiguration,jedisPoolConfig,jedisConnectionFactory,redisTemplate]; root of factory hierarchyerere
[INFO ][ContextLoader(initWebApplicationContext:325)] Root WebApplicationContext: initialization completed in 361 ms
[ERROR][StandardContext(filterStart:4592)] Exception starting filter springSessionRepositoryFilter
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:575)

这是我的日志.我不知道如何解决这个问题.
看起来已经创建了 RedisHttpSessionConfiguration bean,
为什么过滤器 bean 仍未定义?

here's my log. I don't know how to solve this problem.
it looks like the RedisHttpSessionConfiguration bean had already been created,
why the filter bean still not defined ?

我不能改成spring4,因为我的公司不让我
真的需要你的帮助,谢谢

and i cant change to spring4 because my company won't let me
really need your help, thanks

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- redis -->
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
</bean>

<bean id="jedisConnectionFactory"     class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="127.0.0.1"/>
<property name="port" value="6739" />
<property name="password" value="" />
<property name="timeout" value="1800" />
<property name="poolConfig" ref="jedisPoolConfig" />
<property name="usePool" value="true" />
</bean>

<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory" />
</bean>

<!-- session redis -->
<bean id="redisHttpSessionConfiguration" class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration">
<property name="maxInactiveIntervalInSeconds" value="1800" />
</bean>
</beans>

这是我的配置文件,我的项目使用了嵌入式tomcat,并没有web.xml ,我通过

this is my config file, and my project used embedded tomcat, and didn't have web.xml , I add the listener and filters by

 ctx.addParameter("contextConfigLocation", "file:"+getHomePath()+"conf/applicationContext.xml");
      ctx.addApplicationListener(new ApplicationListener("org.springframework.web.context.ContextLoaderListener",true));
      ctx.addApplicationListener(new ApplicationListener("org.springframework.web.context.request.RequestContextListener",true));



    org.apache.tomcat.util.descriptor.web.FilterDefspringSessionRepositoryFilterDef =new org.apache.tomcat.util.descriptor.web.FilterDef();
    org.apache.tomcat.util.descriptor.web.FilterMap springSessionRepositoryFilterMapper = new org.apache.tomcat.util.descriptor.web.FilterMap();

    springSessionRepositoryFilterDef.setFilterName("springSessionRepositoryFilter");
    springSessionRepositoryFilterDef.setFilterClass(org.springframework.web.filter.DelegatingFilterProxy.class.getCanonicalName());
    ctx.addFilterDef(springSessionRepositoryFilterDef);
    springSessionRepositoryFilterMapper.setFilterName("springSessionRepositoryFilter");
    springSessionRepositoryFilterMapper.addURLPattern("/*");
    ctx.addFilterMap(springSessionRepositoryFilterMapper);

非常感谢

推荐答案

您需要将 <context:annotation-config/> 添加到您的 Spring XML 配置中,以便能够处理 <代码>@Configuration 类.

You need to add <context:annotation-config/> to your Spring XML config in order to enable handling of @Configuration classes.

如您的日志输出所示,RedisHttpSessionConfiguration 当前仅注册为常规 bean,但未处理其中的 bean 定义.

As shown in your log output, RedisHttpSessionConfiguration is currently only registered as a regular bean, but bean definitions inside it are not handled.

这篇关于spring session redis'没有定义名为'springSessionRepositoryFilter'的bean'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆