问题描述:
使用StringRedisTemplate 时出现异常
Consider defining a bean of type 'org.springframework.data.redis.core.StringRedisTemplate' in your configuration.

问题分析:
(1)查看pom文件中是否引入相关依赖(这里我使用的是springboot3.4.0的版本)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!-- 显式指定 Lettuce 版js本 --> <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: datphpa: redis: host: localhost port: 6379
(3)检查自动配置
排除自动配置类:检查@SpringBootApplication www.cppcns.com;或@EnableAutoConfiguration是否排编程除了RedisAutoConfiguration
// 错误示例:排除了 Redis 自动配置
@SpringBootApplication(exclude = {RedisAutoConfiguration.class})
public class MyApplication { ... }到此这篇关于SpringBoot3.4.0无法找到StringRedisTemplate bean的android问题Consider defining a bean of type ‘org.springframework的文章就介绍到这了,更多相关SpringBoot3.4.0无法找到StringRedisTemplate bean内容请搜索编程客栈(www.cppcns.com)以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程客栈(www.cppcns.com)!
本文标题: SpringBoot3.4.0无法找到StringRedisTemplate bean的问题Consider defining a bean of type ‘org.springframework
本文地址: http://www.cppcns.com/ruanjian/java/705269.html