#7046·spring-ai

spring-ai-starter-vector-store-pgvector transitively pulls in spring-boot-starter-jdbc causing DataSource auto-configuration failure

Author: zaojiaociCreated Sep 24, 2026Updated Sep 28, 2026
Labelsstatus: waiting-for-triage

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 driver

spring-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

  1. Create a Spring Boot project with spring-ai-alibaba-starter-dashscope (or any chat model starter) — no JDBC, no database
  2. Add spring-ai-starter-vector-store-pgvector as a dependency:
xml
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-vector-store-pgvector</artifactId>
    <optional>true</optional>
</dependency>
  1. 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:

yaml
spring:
  autoconfigure:
    exclude:
      - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
      - org.springframework.ai.vectorstore.pgvector.autoconfigure.PgVectorStoreAutoConfiguration

Even 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

  1. Don't transitively pull in spring-boot-starter-jdbc from spring-ai-starter-vector-store-pgvector. Instead, depend on the specific JDBC modules needed (e.g., spring-jdbc) without triggering DataSourceAutoConfiguration.

  2. Or, make PgVectorStoreAutoConfiguration check for DataSource bean availability before attempting to create the vector store, so it gracefully no-ops when no DataSource is configured.

  3. Or, provide clear documentation on how to conditionally include pgvector alongside SimpleVectorStore in 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