spring-ai-starter-vector-store-pgvector transitively pulls in spring-boot-starter-jdbc causing DataSource auto-configuration failure
Bug Report
Title: spring-ai-starter-vector-store-pgvector transitively pulls in spring-boot-starter-jdbc, causing DataSource auto-configuration failure when no database is configured
Description
When adding spring-ai-starter-vector-store-pgvector as an optional dependency to a project that doesn't use JDBC/DataSource, the application fails to start with:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to determine a suitable driver class
Action:
Consider revisiting the entries where you likely made a mistake or exclude the auto-configuration classes.Root Cause
The dependency chain is:
spring-ai-starter-vector-store-pgvector
└── spring-boot-starter-jdbc
└── spring-boot-jdbc
└── HikariCP + postgresql driverspring-boot-starter-jdbc triggers DataSourceAutoConfiguration, which requires a configured database URL. Even when pgvector is marked as <optional>true</optional> in Maven, the dependency is still included in the current project (Maven's <optional> only prevents transitive propagation to downstream projects, not inclusion in the current one).
Reproduction
- Create a Spring Boot project with
spring-ai-alibaba-starter-dashscope(or any chat model starter) — no JDBC, no database - Add
spring-ai-starter-vector-store-pgvectoras a dependency:
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-pgvector</artifactId>
<optional>true</optional>
</dependency>- Run the application — it fails immediately on startup.
Expected Behavior
Adding pgvector as an optional dependency should not break application startup when no database is configured. Users should be able to:
- Use
SimpleVectorStore(in-memory) by default - Switch to pgvector by simply adding the dependency + configuring the database URL
- Have both options coexist without manual exclusions
Actual Behavior
Application fails to start unless you manually exclude both:
spring:
autoconfigure:
exclude:
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
- org.springframework.ai.vectorstore.pgvector.autoconfigure.PgVectorStoreAutoConfigurationEven with both exclusions, edge cases may remain depending on the Spring Boot version.
Workaround
Remove the spring-ai-starter-vector-store-pgvector dependency entirely when not using pgvector. Use SimpleVectorStore for in-memory vector storage. Re-add the dependency only when a PostgreSQL instance is available and configured.
Suggested Fix
Don't transitively pull in
spring-boot-starter-jdbcfromspring-ai-starter-vector-store-pgvector. Instead, depend on the specific JDBC modules needed (e.g.,spring-jdbc) without triggeringDataSourceAutoConfiguration.Or, make
PgVectorStoreAutoConfigurationcheck forDataSourcebean availability before attempting to create the vector store, so it gracefully no-ops when no DataSource is configured.Or, provide clear documentation on how to conditionally include pgvector alongside
SimpleVectorStorein the same project.
Environment
- Spring Boot: 4.1.1
- Spring AI: 2.0.0-M1
- Spring AI Alibaba: 2.0.0-M1.1
- Java: 17
- Build tool: Maven
Source: spring-projects/spring-ai