Spring AI 1.0

When upgrading to Spring AI 1.0, refer to the Upgrade Notes to find out about newly introduced APIs, deprecated APIs, and information about breaking changes.

The io.arconia.rewrite.spring.ai.UpgradeSpringAi_1_0 recipe automates most of the changes introduced in Spring AI 1.0. You can use it to update your project from the milestone releases to the latest Spring AI 1.0.x release.

The recipe will:

  • Upgrade all org.springframework.ai dependencies to the 1.0.x release line.

  • Rename Spring AI configuration properties to match the new property names.

  • Rename the model provider starters to the new spring-ai-starter-model-<provider> scheme. This covers Anthropic, Azure OpenAI, Bedrock (and Bedrock Converse), Hugging Face, MiniMax, Mistral AI, OCI GenAI, Ollama, OpenAI, PostgresML, Stability AI, Transformers, Vertex AI (embedding and Gemini), Watsonx AI, and ZhipuAI.

  • Rename the vector store starters to the new spring-ai-starter-vector-store-<store> scheme. This covers Azure (and Azure Cosmos DB), MariaDB, Chroma, AWS OpenSearch, Neo4j, Milvus, Couchbase, Cassandra, Elasticsearch, pgvector, Typesense, Oracle, OpenSearch, SAP HANA, Pinecone, GemFire, Weaviate, MongoDB Atlas, Qdrant, and Redis.

  • Rename the JDBC, Cassandra, and Neo4j chat-memory artifacts (model, autoconfigure, starter) to insert a repository segment in their name (for example, spring-ai-model-chat-memory-jdbcspring-ai-model-chat-memory-repository-jdbc).

  • Rename the MCP starters (such as spring-ai-mcp-client-spring-boot-starter and spring-ai-mcp-server-webflux-spring-boot-starter) to the new spring-ai-starter-mcp-{client,server}[-{webflux,webmvc}] scheme.

  • Relocate types to their new packages, including:

    • Content, Media, and MediaContent from org.springframework.ai.model to org.springframework.ai.content.

    • KeywordMetadataEnricher and SummaryMetadataEnricher to org.springframework.ai.model.transformer.

    • FactCheckingEvaluator and RelevancyEvaluator to org.springframework.ai.chat.evaluation.

    • QuestionAnswerAdvisor and VectorStoreChatMemoryAdvisor to the vectorstore advisor sub-package.

    • RetrievalAugmentationAdvisor and PromptAssert to the new org.springframework.ai.rag packages.

    • Chat-memory repository types (JdbcChatMemoryRepository and the JDBC, Cassandra, Neo4j auto-configurations) to their new repository sub-packages (for example, org.springframework.ai.chat.memory.jdbcorg.springframework.ai.chat.memory.repository.jdbc).

  • Rename ChatClient.tools(String…​) to toolNames(…​) and tools(FunctionCallback/ToolCallback/ToolCallbackProvider/List…​) to toolCallbacks(…​), with the same renames applied to ChatClient.Builder.defaultTools(…​).

  • Replace the CHAT_MEMORY_CONVERSATION_ID_KEY and CHAT_MEMORY_RETRIEVE_SIZE_KEY constants with ChatMemory.CONVERSATION_ID and the advisor TOP_K constant.

  • Automatically add the spring-ai-vector-store, spring-ai-rag, and spring-ai-advisors-vector-store dependencies when the corresponding APIs are in use.

  • Add the missing Map argument to the MistralAiApi.ChatCompletionRequest.ResponseFormat constructor.

Run the recipe

You can apply this recipe with any OpenRewrite-compatible tool. The tabs below show three of them: the Arconia CLI, the OpenRewrite Gradle plugin, and the OpenRewrite Maven plugin. See Running Recipes for a comparison of when to pick each one.

  • Arconia CLI

  • Gradle

  • Maven

arconia update spring-ai --to-version=1.0

First, create an init.gradle file in your project root with the following content.

initscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2" }
    }
    dependencies {
        classpath("org.openrewrite:plugin:latest.release")
    }
}

rootProject {
    plugins.apply(org.openrewrite.gradle.RewritePlugin)
    dependencies {
        rewrite("io.arconia.migrations:rewrite-spring:latest.release")
    }

    afterEvaluate {
        if (repositories.isEmpty()) {
            repositories {
                mavenCentral()
            }
        }
    }

    configurations.named("rewrite") {
        canBeConsumed = false
    }
}

Then, run the following command.

./gradlew rewriteRun \
    --init-script init.gradle \
    -DactiveRecipe=io.arconia.rewrite.spring.ai.UpgradeSpringAi_1_0

You can remove the init.gradle file afterwards.

./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=io.arconia.migrations:rewrite-spring:LATEST \
  -Drewrite.activeRecipes=io.arconia.rewrite.spring.ai.UpgradeSpringAi_1_0