记一次springboot配置redis项目启动时的一个奇怪的错误

2022-07-17,,,,

springboot配置redis项目启动时错误

在刚开始学redis时,我照着网上的教程,把redis和jedis整合到spring boot,整合完毕后,启动项目总是失败

总是爆出下面的错误

correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.repositoryconfigurationsource

***************************
application failed to start
***************************
 
description:
 
an attempt was made to call the method org.springframework.data.repository.config.repositoryconfigurationsource.getattribute(ljava/lang/string;)ljava/lang/string; but it does not exist. its class, org.springframework.data.repository.config.repositoryconfigurationsource, is available from the following locations:
 
jar:file:/d:/m2/repository/org/springframework/data/spring-data-commons/2.0.10.release/spring-data-commons-2.0.10.release.jar!/org/springframework/data/repository/config/repositoryconfigurationsource.class
 
it was loaded from the following location:
 
file:/d:/m2/repository/org/springframework/data/spring-data-commons/2.0.10.release/spring-data-commons-2.0.10.release.jar
 
action:
 
correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.repositoryconfigurationsource
 
2018-11-22 13:03:51.398 info 2196 --- [ main] configservletwebserverapplicationcontext : closing org.springframework.boot.web.servlet.context.annotationconfigservletwebserverapplicationcontext@1a451d4d: startup date [thu nov 22 13:03:50 cst 2018]; root of context hierarchy
 
process finished with exit code 1

然后我在网上找了很久,都没有关于这个错误的解决办法,偶然看到一篇博客,它在启动项目时也出现了类型错误,也是jar包冲突,然后那个博主是通过改redis和jedis的版本号解决的,我也把版本号都改成和那个博主相同的,但启动后还是出现相同的错误。

后来就想如果我把版本号都去掉,让“spring-boot-starter-parent”自动为我们提供对应版本的jar包,这样就可以避免自己指定版本号时,可能会有一些意想不到的冲突。于是我就把redis和jedis的版本号都去掉,果然项目就可以正常启动了~~

what a strange error..

解决springboot项目启动时redis报错

出现err client sent auth, but no password is set的问题

首先看下我springboot配置redis的部分如图:

显然上面配置了redis的启动密码为123456,

本地redis版本为3.0.1 在redis.windows.conf文件中requirepass内容也修改了密码为123456,这里说下,在去除requirepass前面的#号时一定注意还有一个空格要去除,不然会报错:

invalid argument during startup: unknown conf file parameter :  requirepass

这时,说明redis密码与springboot的一致,接下来就是启动redis再启动springboot。

我员来的启动方式就是进入到redis的安装目录,执行redis-server.exe,然后正常启动。但是在启动springboot后,调用redis时就报错了,如图:

一开始以为是我pom.xml文件中引入的为2.9.0的redis依赖导致的版本不兼容,一直去找redis的2.9.0的安装包竟然网上没有。浪费了半天时间。

后来才发现,这个报错是告诉我没有设置密码。原因就是启动时的方法错误。

请务必记住,启动本地redis,如果设置了密码记得带上配置文件,启动命令完整为:

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

《记一次springboot配置redis项目启动时的一个奇怪的错误.doc》

下载本文的Word格式文档,以方便收藏与打印。