記一次springboot配置redis項目啟動時的一個奇怪的錯誤
springboot配置redis項目啟動時的錯誤
在剛開始學(xué)redis時,我照著網(wǎng)上的教程,把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
然后我在網(wǎng)上找了很久,都沒有關(guān)于這個錯誤的解決辦法,偶然看到一篇博客,它在啟動項目時也出現(xiàn)了類型錯誤,也是jar包沖突,然后那個博主是通過改redis和jedis的版本號解決的,我也把版本號都改成和那個博主相同的,但啟動后還是出現(xiàn)相同的錯誤。
后來就想如果我把版本號都去掉,讓“spring-boot-starter-parent”自動為我們提供對應(yīng)版本的jar包,這樣就可以避免自己指定版本號時,可能會有一些意想不到的沖突。于是我就把redis和jedis的版本號都去掉,果然項目就可以正常啟動了~~
What a strange error..
解決springboot項目啟動時redis報錯
出現(xiàn)ERR Client sent AUTH, but no password is set的問題
首先看下我springboot配置redis的部分如圖:
顯然上面配置了redis的啟動密碼為123456,
本地redis版本為3.0.1 在redis.windows.conf文件中requirepass內(nèi)容也修改了密碼為123456,這里說下,在去除requirepass前面的#號時一定注意還有一個空格要去除,不然會報錯:
Invalid argument during startup: unknown conf file parameter : requirepass
這時,說明redis密碼與springboot的一致,接下來就是啟動redis再啟動springboot。
我員來的啟動方式就是進入到redis的安裝目錄,執(zhí)行redis-server.exe,然后正常啟動。但是在啟動springboot后,調(diào)用redis時就報錯了,如圖:
一開始以為是我Pom.xml文件中引入的為2.9.0的redis依賴導(dǎo)致的版本不兼容,一直去找Redis的2.9.0的安裝包竟然網(wǎng)上沒有。浪費了半天時間。
后來才發(fā)現(xiàn),這個報錯是告訴我沒有設(shè)置密碼。原因就是啟動時的方法錯誤。
請務(wù)必記住,啟動本地redis,如果設(shè)置了密碼記得帶上配置文件,啟動命令完整為:
redis-server.exe redis.windows.conf
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- 解決springboot+activemq啟動報注解錯誤的問題
- springboot項目啟動,但是訪問報404錯誤的問題
- 解決Springboot啟動報錯:類文件具有錯誤的版本61.0,應(yīng)為?52.0
- 啟動springboot項目時報錯:無法訪問org.springframework.web.bind.annotation.GetMapping …具有錯誤的版本 61.0,應(yīng)為52.0?的解決方案
- SpringBoot項目啟動打包報錯類文件具有錯誤的版本 61.0, 應(yīng)為 52.0的解決方法
- 啟動SpringBoot報JavaMail加載錯誤的原因分析和解決
- springboot項目啟動類錯誤(找不到或無法加載主類 com.**Application)
- spring boot啟動出現(xiàn)Unable to start ServletWebServerApplicationContext due to missing ServletWebServer錯誤解決
相關(guān)文章
springboot集成swagger、knife4j及常用注解的使用
這篇文章主要介紹了springboot集成swagger、knife4j及常用注解的使用,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07MyBatis實現(xiàn)動態(tài)SQL的實現(xiàn)方法
這篇文章主要介紹了MyBatis實現(xiàn)動態(tài)SQL的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12springboot接口接收數(shù)組及多個參數(shù)的問題及解決
這篇文章主要介紹了springboot接口接收數(shù)組及多個參數(shù)的問題及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-11-11Java Socket編程簡介_動力節(jié)點Java學(xué)院整理
這篇文章主要介紹了Java Socket編程簡介的相關(guān)知識,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-05-05