You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Redis OM Spring+Spring Boot3+JDK17启动报错:找不到redisJSONKeyValueTemplate Bean

解决Redis OM Spring启动时找不到redisJSONKeyValueTemplate Bean的问题

可能的原因及对应解决步骤

1. 检查Gradle依赖是否完整且版本兼容

确保build.gradle中引入了Redis OM Spring核心依赖,并且版本与Spring Boot 3.0.2兼容:

dependencies {
    implementation 'com.redis.om:redis-om-spring:0.6.4'
    implementation 'org.springframework.boot:spring-boot-starter-data-redis'
    // 保留项目原有其他依赖
}

你的版本组合(Redis OM Spring 0.6.4 + Spring Boot 3.0.2)是兼容的,但要确认没有遗漏上述核心依赖。

2. 给主启动类添加必要的注解

在SkeletonApplication类上添加@EnableRedisDocumentRepositories注解,该注解会触发Redis OM Spring的自动配置流程,包含redisJSONKeyValueTemplate Bean的创建:

@SpringBootApplication
@EnableRedisDocumentRepositories
public class SkeletonApplication {
    public static void main(String[] args) {
        SpringApplication.run(SkeletonApplication.class, args);
    }
}

如果实体类不在主启动类的同级/子包下,需指定扫描路径:

@EnableRedisDocumentRepositories(basePackages = "your.entity.package.path")

3. 确认Redis连接配置正确

在application.properties或application.yml中检查Redis连接参数:

spring.data.redis.host=localhost
spring.data.redis.port=6379
# 若Redis设置了密码,添加以下配置
# spring.data.redis.password=your-redis-password

错误的连接配置会导致Spring无法初始化Redis相关核心Bean。

4. 验证实体类的Redis OM注解

确保实体类正确标注@Document注解,示例:

@Document
public class Person {
    @Id
    private String id;
    private String name;
    // 字段、getter/setter等
}

未正确标注的实体类会导致Redis OM Spring的自动配置逻辑不触发。

5. 清理缓存后重新构建项目

执行Gradle命令清理编译缓存并重新构建:

./gradlew clean build

完成后重新启动应用。


内容的提问来源于stack exchange,提问作者Sukh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 02:31:15