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.clientsgroupId>
		    <artifactId>jedisartifactId>
		    <version>2.9.0version>
		dependency>
		<dependency>
		    <groupId>org.springframework.sessiongroupId>
		    <artifactId>spring-session-data-redisartifactId>
		    <version>1.2.0.RELEASEversion>
		dependency>
		<dependency>
		    <groupId>org.springframework.datagroupId>
		    <artifactId>spring-data-redisartifactId>
		    <version>1.6.0.RELEASEversion>
		dependency>
		<dependency>
		       <groupId>org.springframework.sessiongroupId>
		       <artifactId>spring-sessionartifactId>
		       <version>1.3.0.RELEASEversion>
		dependency>
		<dependency>
		    <groupId>org.apache.commonsgroupId>
		    <artifactId>commons-pool2artifactId>
		    <version>2.6.0version>
		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"> 
		
		<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.propertiesvalue>
			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>

你可能感兴趣的:(开发总结)