问题概述
在项目编写过程中,因为项目需要遂加入了 session 管理的包,启动项目测试时,便出现启动失败,错误信息 “ An attempt was made to call the method org.springframework.boot.autoconfigure.session.RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.setCleanupCron(Ljava/lang/String;)V but it does not exist. Its class,” 尝试调用该方法,但是该方法不存在 ,具体的错误内容如下图:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-19 14:11:41.241 ERROR 3968 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method org.springframework.boot.autoconfigure.session.RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.setCleanupCron(Ljava/lang/String;)V but it does not exist. Its class, org.springframework.boot.autoconfigure.session.RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration, is available from the following locations:
jar:file:/D:/Install_Applications/apache-maven-3.5.3/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.0.6.RELEASE/spring-boot-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class
It was loaded from the following location:
file:/D:/Install_Applications/apache-maven-3.5.3/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.0.6.RELEASE/spring-boot-autoconfigure-2.0.6.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.boot.autoconfigure.session.RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration
如下图:
解决办法
关于这个问题,主要是为了在项目的实际生产环境中实现横向扩展时的 Session 管理而引入的,所以在项目的 pom.xml 文件中引入了 “ spring-session ” session 管理的包,如下图:
其实这个问题很简单,只需要在项目的配置文件中加入如下配置即可,如下图:
2019年4月补充:由于图片掉了,博主不可能又去复现问题了,再把图贴上来,博主时间都比较紧张,所以这儿简单的描述哈问题思路,自己解决:
这儿是一个坑,你需要注意以下,一般出现这个问题的是Maven项目,并且通过自动的包管理策略,在项目中使用时,不乏出现兼容的问题,如何避免这类的问题呢,还有个问题需要注意的是,在使用Maven前,需要注意配置Maven的镜像地址,最好为国内的,否则你踩这样的坑便是家常便饭了。希望可以帮助到你。
通过以上修改后,即可再次成功启动项目了,如下图:
好了,关于 An attempt was made to call the method org.springframework.boot...RedisSessionConfiguration 的解决办法 就写到这儿了,如果还有什么疑问或遇到什么问题欢迎扫码提问,也可以给我留言哦,我会一一详细的解答的。
歇后语:“ 共同学习,共同进步 ”,也希望大家多多关注CSND的IT社区。
作 者: | 华 仔 |
联系作者: | who.seek.me@java98k.vip |
来 源: | CSDN (Chinese Software Developer Network) |
原 文: | https://blog.csdn.net/Hello_World_QWP/article/details/83182196 |
版权声明: | 本文为博主原创文章,请在转载时务必注明博文出处! |