Bug description More info here. I am trying to configure RedisVector store via these instructions. However, it doesn't work, instead when I add debug I see
RedisVectorStoreAutoConfiguration:
Did not match:
- @ConditionalOnBean (types: org.springframework.data.redis.connection.jedis.JedisConnectionFactory; SearchStrategy: all) did not find any beans of type org.springframework.data.redis.connection.jedis.JedisConnectionFactory (OnBeanCondition)
Matched:
- @ConditionalOnClass found required classes 'redis.clients.jedis.JedisPooled', 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory', 'org.springframework.ai.vectorstore.RedisVectorStore', 'org.springframework.ai.embedding.EmbeddingModel' (OnClassCondition)
To get it to work I have to add
@Bean
public JedisConnectionFactory redisConnectionFactory() {
return new JedisConnectionFactory();
}
Which is not documented anywhere as far as I can find.
Environment Spring AI 1.0.0.m4 and Java 23
Steps to reproduce In my case I just had to add the lib and debug but ftr here is my entire build.gradle
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.10.2/userguide/building_java_projects.html in the Gradle documentation.
* This project uses @Incubating APIs which are subject to change.
*/
plugins {
id 'com.google.cloud.tools.jib' version '3.4.4'
// Apply the application plugin to add support for building a CLI application in Java.
id 'java'
id 'org.springframework.boot' version '3.3.4'
id "io.spring.dependency-management" version '1.1.6'
id 'idea'
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven {
url 'https://repo.spring.io/milestone'
}
}
group = 'org.cbusha'
version = '0.0.1-SNAPSHOT'
ext {
springAiVersion = '1.0.0-M3'
}
dependencies {
implementation platform("org.springframework.ai:spring-ai-bom:${springAiVersion}")
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-logging'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.data:spring-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation 'org.springframework.integration:spring-integration-mqtt:6.3.4'
implementation "org.springframework.ai:spring-ai-openai-spring-boot-starter:${springAiVersion}"
implementation "org.springframework.ai:spring-ai-anthropic-spring-boot-starter:${springAiVersion}"
implementation "org.springframework.ai:spring-ai-pinecone-store-spring-boot-starter:${springAiVersion}"
implementation "org.springframework.ai:spring-ai-redis-store-spring-boot-starter:${springAiVersion}"
implementation 'org.springframework.boot:spring-boot-starter-websocket:3.3.5'
implementation 'com.github.ben-manes.caffeine:caffeine'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
testing {
suites {
// Configure the built-in test suite
test {
// Use JUnit Jupiter test framework
useJUnitJupiter('5.10.3')
}
}
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(23)
}
}
Expected behavior I would expect either the documentation shows the need to add the Connection Factory bean or that it would work without declaring it.
Minimal Complete Reproducible example Should be available here https://github.com/jrgleason/spring-ai-example/tree/CHANGES_AND_FIXES
Comment From: jrgleason
I made some progress using the manual config
@Bean(name = "customRedisVectorStore")
public RedisVectorStore redisVectorStore(EmbeddingModel embeddingModel, JedisConnectionFactory jedisConnectionFactory,
ObjectProvider<ObservationRegistry> observationRegistry,
ObjectProvider<VectorStoreObservationConvention> customObservationConvention,
BatchingStrategy batchingStrategy) {
var config = RedisVectorStore.RedisVectorStoreConfig.builder()
.withIndexName("spring-ai-example")
.withPrefix("prefix")
.build();
return new RedisVectorStore(config, embeddingModel,
new JedisPooled(jedisConnectionFactory.getHostName(), jedisConnectionFactory.getPort()),
true, observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP),
customObservationConvention.getIfAvailable(() -> null), batchingStrategy);
}
But it looks like it is still missing another bean
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'redisTemplate' available
Comment From: jrgleason
Yeah looks like at a minimum the documents should be updated to
- Make sure to tell everyone to create their own beans like
@Bean
public JedisConnectionFactory redisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate<String, Message> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Message> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new StringRedisSerializer());
return template;
}
2. I would add to the manual config section to tell people that if they want to use multiple vector stores they need to use manual configuration.