No bean named 'springSessionRepositoryFilter' is defined

项目环境

jdk:1.7
spring:4.1.6

问题

为 spring web 项目实现 redis session 共享时,web.xml 中配置了springSessionRepositoryFilter,但启动一直出现No bean named 'springSessionRepositoryFilter' is defined。找遍各种原因,最后是包不对,少了 spring-session-data-redis包,网上大部分教程都是两个包,有的是三个包,针对的应该是高版本的 spring。低版本的应该是需要四个包:

		<dependency>
		    <groupId>redis.clients</groupId>
		    <artifactId>jedis</artifactId>
		    <version>2.9.0</version>
		</dependency>
		<dependency>
		    <groupId>org.springframework.session</groupId>
		    <artifactId>spring-session-data-redis</artifactId>
		    <version>1.2.0.RELEASE</version>
		</dependency>
		<dependency>
		    <groupId>org.springframework.data</groupId>
		    <artifactId>spring-data-redis</artifactId>
		    <version>1.6.0.RELEASE</version>
		</dependency>
		<dependency>
		       <groupId>org.springframework.session</groupId>
		       <artifactId>spring-session</artifactId>
		       <version>1.3.0.RELEASE</version>
		</dependency>
		<dependency>
		    <groupId>org.apache.commons</groupId>
		    <artifactId>commons-pool2</artifactId>
		    <version>2.6.0</version>
		</dependency>

applicationContext.xml

context:annotation-config/>
	<context:component-scan
		base-package="org.springframework.web.filter.DelegatingFilterProxy" />

	<context:property-placeholder location="classpath:redis.properties" />

	<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"> 
		<!-- 过期时间100分钟 -->
		<property name="maxInactiveIntervalInSeconds" value="6000"></property>
	</bean>  

	<bean id="propertyConfigurerRedis"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="order" value="1" />
		<property name="ignoreUnresolvablePlaceholders" value="true" />
		<property name="systemPropertiesMode" value="1" />
		<property name="searchSystemEnvironment" value="true" />
		<property name="locations">
			<list>
				<value>classpath:redis.properties</value>
			</list>
		</property>
	</bean>

	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
		<property name="maxIdle" value="${redis.maxIdle}" />
		<property name="testOnBorrow" value="${redis.testOnBorrow}" />
	</bean>

	<bean id="jedisConnectionFactory"
		class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
		<property name="usePool" value="true"></property>
		<property name="hostName" value="${redis.host}" />
		<property name="port" value="${redis.port}" />
		<property name="password" value="${redis.password}" />
		<property name="timeout" value="${redis.timeout}" />
		<property name="database" value="${redis.default.db}"></property>
		<constructor-arg index="0" ref="jedisPoolConfig" />
	</bean>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值