springboot配置redis项目启动时错误怎么解决

这篇“springboot配置redis项目启动时错误怎么解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“springboot配置redis项目启动时错误怎么解决”文章吧。

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项目启动时错误怎么解决  springboot 第1张

解决springboot项目启动时redis报错

出现ERR Client sent AUTH, but no password is set的问题

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

springboot配置redis项目启动时错误怎么解决  springboot 第2张

显然上面配置了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时就报错了,如图:

springboot配置redis项目启动时错误怎么解决  springboot 第3张

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

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

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

redis-server.exe redis.windows.conf

以上就是关于“springboot配置redis项目启动时错误怎么解决”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注蜗牛博客行业资讯频道。

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接