JDK1.7
Tomcat8
Redis的SV 3.0
Spring3.2.14,jedis 2.8.1,春季會議1.2,彈簧數據redis的1.7春季會議redis的 '命名沒有豆 'springSessionRepositoryFilter' 被定義'
[INFO ][XmlBeanDefinitionReader(loadBeanDefinitions:316)] Loading XML bean definitions
[INFO ][DefaultListableBeanFactory(preInstantiateSingletons:603)] Pre-instantiating singletons in org.s[email protected]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已經創建,
爲什麼filter bean仍然沒有定義?
,我不能改變spring4,因爲我的公司是不會讓我
真的需要你的幫助,感謝
<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中,我通過
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);
添加監聽器和過濾器非常感謝你
你能發佈你的配置嗎?另外,嘗試調試'SpringHttpSessionConfiguration.springSessionRepositoryFilter'來驗證bean是否被創建。 – codependent
@codependent我編輯了我的問題,謝謝 – wade