Spring AI 1.1
When upgrading to Spring AI 1.1, refer to the Upgrade Notes for newly introduced APIs, deprecated APIs, and breaking changes.
The io.arconia.rewrite.spring.ai1.UpgradeSpringAi_1_1 recipe automates most of the changes introduced in Spring AI 1.1. You can use it to update your project to the latest Spring AI 1.1.x release.
The recipe will:
-
Upgrade all
org.springframework.aidependencies to the 1.1.x release line. -
For Ollama: flag the deprecated
spring.ai.ollama.chat.optionsproperties (use-n-u-m-a,low-v-r-a-m,f16-k-v,logits-all,vocab-only,use-m-lock,tfs-z,mirostat,mirostat-tau,mirostat-eta,penalize-newline) with a comment noting they are no longer supported by the Ollama Server. -
Migrate to the new
AssistantMessage,EmbeddingOptions,QuestionAnswerAdvisor, andToolResponseMessagebuilders. -
For Bedrock: rename
BedrockTitanEmbeddingOptions.Builder.withInputType(…)toinputType(…). -
For Text-to-Speech: move the speech model types from
org.springframework.ai.openai.audio.speechto the new vendor-agnosticorg.springframework.ai.audio.ttspackage, renamingSpeechMessage→TextToSpeechMessage,SpeechModel→TextToSpeechModel,SpeechPrompt→TextToSpeechPrompt,SpeechResponse→TextToSpeechResponse, andStreamingSpeechModel→StreamingTextToSpeechModel. -
For MCP (Model Context Protocol): rename
spring-ai-autoconfigure-mcp-clientandspring-ai-autoconfigure-mcp-serverto add the-commonsuffix; automatically add the transport-specific autoconfigure dependencies (spring-ai-autoconfigure-mcp-{client-{httpclient,webflux},server-{webflux,webmvc}}) when the corresponding autoconfiguration types are used; relocate the MCP client autoconfigure types fromorg.springframework.ai.mcp.client.autoconfiguretoorg.springframework.ai.mcp.client.common.autoconfigure(and the transport-specific types to their respectivehttpclient/webfluxsub-packages); move server autoconfigure types underorg.springframework.ai.mcp.server.common.autoconfigure; and renameMcpWebFluxServerAutoConfigurationandMcpWebMvcServerAutoConfigurationtoMcpServerSseWebFluxAutoConfigurationandMcpServerSseWebMvcAutoConfiguration.
See its entry in the Recipe Catalog for the full list of recipes this upgrade applies, each with its options and a before/after example.
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.1
First, create an init.gradle file in your project root with the following content.
initscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath("org.openrewrite:plugin:latest.release")
}
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("io.arconia.migrations:rewrite-spring:latest.release")
}
// Remove when project repositories are disabled
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
configurations.named("rewrite") {
canBeConsumed = false
}
}
Then, run the following command.
./gradlew rewriteRun \
--init-script init.gradle \
--no-parallel \
-DactiveRecipe=io.arconia.rewrite.spring.ai1.UpgradeSpringAi_1_1
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.ai1.UpgradeSpringAi_1_1