问题

学习Langchain4j过程中,想用Redisearch作为向量数据库,出现了创建Bean异常:

2025-08-22T10:11:43.389+08:00  WARN 15268 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'commonConfig': Unsatisfied dependency expressed through field 'redisEmbeddingStore': Error creating bean with name 'redisEmbeddingStore' defined in class path resource [dev/langchain4j/community/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.class]: Failed to instantiate [dev.langchain4j.community.store.embedding.redis.RedisEmbeddingStore]: Factory method 'redisEmbeddingStore' threw exception with message: Invalid rule type
2025-08-22T10:11:43.398+08:00  INFO 15268 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2025-08-22T10:11:43.405+08:00  INFO 15268 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-08-22T10:11:43.431+08:00 ERROR 15268 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'commonConfig': Unsatisfied dependency expressed through field 'redisEmbeddingStore': Error creating bean with name 'redisEmbeddingStore' defined in class path resource [dev/langchain4j/community/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.class]: Failed to instantiate [dev.langchain4j.community.store.embedding.redis.RedisEmbeddingStore]: Factory method 'redisEmbeddingStore' threw exception with message: Invalid rule type

问题分析

redis-search版本和LangChain4j版本不匹配,当换上2.4.9的search版本时,SpringBoot能正确创建Bean注入容器,并实现Redis存储向量。

# 安装redisearch的docker命令
 docker run -d --name redis-vector -p 6379:6379 redislabs/redisearch:2.4.9

在这里插入图片描述

总结

需要注意版本兼容性问题

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐