SpringBoot3.4.0無法找到StringRedisTemplate?bean的問題Consider?defining?a?bean?of?type?‘org.springframework
問題描述:
使用StringRedisTemplate 時出現(xiàn)異常
Consider defining a bean of type 'org.springframework.data.redis.core.StringRedisTemplate' in your configuration.
問題分析:
(1)查看pom文件中是否引入相關(guān)依賴(這里我使用的是springboot3.4.0的版本)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!-- 顯式指定 Lettuce 版本 --> <dependency> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> <version>6.2.4.RELEASE</version> <!-- 匹配 Spring Boot 3.4.0 的推薦版本 --> </dependency>
(2)Redis 配置缺失(springboot3如下,springboot2將data去掉)
spring: data: redis: host: localhost port: 6379
(3)檢查自動配置
排除自動配置類:檢查 @SpringBootApplication 或 @EnableAutoConfiguration 是否排除了 RedisAutoConfiguration
// 錯誤示例:排除了 Redis 自動配置 @SpringBootApplication(exclude = {RedisAutoConfiguration.class}) public class MyApplication { ... }
到此這篇關(guān)于SpringBoot3.4.0無法找到StringRedisTemplate bean的問題Consider defining a bean of type ‘org.springframework的文章就介紹到這了,更多相關(guān)SpringBoot3.4.0無法找到StringRedisTemplate bean內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
解決Error occurred during initialization o
這篇文章主要介紹了解決Error occurred during initialization of VM Java虛擬機初始化失敗問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2025-03-03JAVA Iterator接口與增強for循環(huán)的實現(xiàn)
這篇文章主要介紹了JAVA Iterator接口與增強for循環(huán)的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11詳解PowerDesigner之CDM、PDM、SQL之間轉(zhuǎn)換
這篇文章主要介紹了詳解PowerDesigner之CDM、PDM、SQL之間轉(zhuǎn)換的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-10-10Spring?Boot之Validation自定義實現(xiàn)方式的總結(jié)
這篇文章主要介紹了Spring?Boot之Validation自定義實現(xiàn)方式的總結(jié),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-07-07