开发者社区> 问答> 正文

Spring整合Redis来实现session共享,项目启动报错?报错

最近在学习分布式相关的东东。

搭了一个spring+springMVC+mybatis框架练手(spring用的是3.2.4,这个不会影响吧?)。

现在想用redis来实现多个tomcat的session共享。

在网上百度了一些教程,但是项目启动的报错,错误如下:

严重: Context initialization failed
java.lang.IllegalStateException: CGLIB is required to process @Configuration classes. Either add CGLIB to the classpath or remove the following @Configuration bean definitions: [org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration#0, org.springframework.scheduling.annotation.SchedulingConfiguration]


java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Thu Nov 10 23:01:26 CST 2016]; root of context hierarchy


=======================================================

是spring配置文件中关于redis、session的配置如下:

<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
		<property name="maxIdle" value="300" />
		<property name="maxActive" value="600" />
		<property name="maxWait" value="1000" />
		<property name="testOnBorrow" value="true" />
	</bean>
	<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
		p:host-name="127.0.0.1" p:port="6379" p:password="123456" p:pool-config-ref="poolConfig" />

	<!-- redis session -->
	<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/>



web.xml配置如下:

<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>



有没有老手帮忙看看是啥问题,或者有比较详细的教程供我参考下。



展开
收起
爱吃鱼的程序员 2020-06-08 20:47:50 936 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    呵呵,看来你也是解决多服务器哈,我以前看见的也是redis+ <spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,SimSun;font-size:14px;line-height:22px;background-color:#FFFFFF;">spring+springMVC+mybatis有公司在用错误信息不是写着缺少cglib类库

    可以使用bbosssession共享,不会与spring产生冲突,无缝与项目集成,参考文档:

    <spanstyle="color:#333333;font-family:"font-size:28px;background-color:#F8F8F8;"><atarget="_blank"rel="nofollow">bbosssession集成权威指南


    用这<atarget="_blank"rel="nofollow">https://github.com/jcoleman/tomcat-redis-session-manager,配置下tomcat就行了还是直接使用springboot搭建吧,省事

    2020-06-08 20:48:08
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Redis集群演化的心路历程——从2.x到3.0时代 立即下载
微博的Redis定制之路 立即下载
云数据库Redis版的开源之路 立即下载