Migrate to Spring AI 2.0

Proprietary

Migrate applications to Spring AI 2.0, from Spring AI 1.x or anything older that UpgradeSpringAi_1_1 migrates. This moves the classes Spring AI 2.0 renamed or relocated, including the MCP annotations and Spring transports that moved into Spring AI and the OpenAI SDK classes that replaced the former OpenAI client, passes options builders to ChatClient, builds MCP resources and tool results through their builders, flattens the .options configuration properties and upgrades Spring AI dependencies to 2.0. Calls to APIs that Spring AI 2.0 removed without a direct replacement, such as internalToolExecutionEnabled(..), toolNames(..) and the OpenAiApi builders, are marked with a TODO comment.

io.moderne.java.spring.ai2.UpgradeSpringAi_2_0
mod run . --recipe=io.moderne.java.spring.ai2.UpgradeSpringAi_2_0

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Migrate to Spring AI 1.1
  2. Pass a ChatOptions.Builder to ChatClient
  3. Change method name org.springframework.ai..* N(java.lang.Integer) to n
  4. Change method name org.springframework.ai.chat.model.ChatModel getDefaultOptions() to getOptions
  5. Remove streamToolCallResponses(..) from tool calling advisor builders
  6. Create MCP resources and tool results with their builders
  7. Add comment to method invocations
  8. Add comment to method invocations
  9. Add comment to method invocations
  10. Add comment to method invocations
  11. Add comment to method invocations
  12. Add comment to method invocations
  13. Change type ToolCallAdvisor to ToolCallingAdvisor
  14. Change type PromptChatMemoryAdvisor to MessageChatMemoryAdvisor
  15. Change type org.springframework.ai.google.genai.GoogleGenAiEmbeddingConnectionDetails to org.springframework.ai.google.genai.embedding.GoogleGenAiEmbeddingConnectionDetails
  16. Change type org.springframework.ai.anthropic.api.AnthropicCacheOptions to org.springframework.ai.anthropic.AnthropicCacheOptions
  17. Change type org.springframework.ai.anthropic.api.AnthropicCacheStrategy to org.springframework.ai.anthropic.AnthropicCacheStrategy
  18. Change type org.springframework.ai.anthropic.api.AnthropicCacheTtl to org.springframework.ai.anthropic.AnthropicCacheTtl
  19. Change type org.springframework.ai.anthropic.api.utils.CacheBreakpointTracker to org.springframework.ai.anthropic.CacheBreakpointTracker
  20. Change type org.springframework.ai.anthropic.api.utils.CacheEligibilityResolver to org.springframework.ai.anthropic.CacheEligibilityResolver
  21. Change type CitationDocument to AnthropicCitationDocument
  22. Change type org.springframework.ai.openai.ImageResponseMetadata to org.springframework.ai.image.ImageResponseMetadata
  23. Change type org.springframework.ai.openai.metadata.audio.OpenAiAudioSpeechResponseMetadata to org.springframework.ai.openai.metadata.OpenAiAudioSpeechResponseMetadata
  24. Change type org.springframework.ai.openai.metadata.audio.OpenAiAudioTranscriptionResponseMetadata to org.springframework.ai.openai.metadata.OpenAiAudioTranscriptionResponseMetadata
  25. Change type OpenAiSdkChatModel to OpenAiChatModel
  26. Change type OpenAiSdkChatOptions to OpenAiChatOptions
  27. Change type OpenAiSdkEmbeddingModel to OpenAiEmbeddingModel
  28. Change type OpenAiSdkEmbeddingOptions to OpenAiEmbeddingOptions
  29. Change type OpenAiSdkImageModel to OpenAiImageModel
  30. Change type OpenAiSdkImageOptions to OpenAiImageOptions
  31. Change type OpenAiSdkImageGenerationMetadata to OpenAiImageGenerationMetadata
  32. Change type OpenAiSdkImageResponseMetadata to OpenAiImageResponseMetadata
  33. Change type OpenAiSdkSetup to OpenAiSetup
  34. Change type io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider to org.springframework.ai.mcp.server.webflux.transport.WebFluxSseServerTransportProvider
  35. Change type io.modelcontextprotocol.server.transport.WebFluxStreamableServerTransportProvider to org.springframework.ai.mcp.server.webflux.transport.WebFluxStreamableServerTransportProvider
  36. Change type io.modelcontextprotocol.server.transport.WebFluxStatelessServerTransport to org.springframework.ai.mcp.server.webflux.transport.WebFluxStatelessServerTransport
  37. Change type io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider to org.springframework.ai.mcp.server.webmvc.transport.WebMvcSseServerTransportProvider
  38. Change type io.modelcontextprotocol.server.transport.WebMvcStreamableServerTransportProvider to org.springframework.ai.mcp.server.webmvc.transport.WebMvcStreamableServerTransportProvider
  39. Change type io.modelcontextprotocol.server.transport.WebMvcStatelessServerTransport to org.springframework.ai.mcp.server.webmvc.transport.WebMvcStatelessServerTransport
  40. Change type io.modelcontextprotocol.client.transport.WebFluxSseClientTransport to org.springframework.ai.mcp.client.webflux.transport.WebFluxSseClientTransport
  41. Change type io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport to org.springframework.ai.mcp.client.webflux.transport.WebClientStreamableHttpTransport
  42. Rename package name org.springaicommunity.mcp.annotation to org.springframework.ai.mcp.annotation
  43. Rename package name org.springaicommunity.mcp.method to org.springframework.ai.mcp.annotation.method
  44. Rename package name org.springaicommunity.mcp.provider to org.springframework.ai.mcp.annotation.provider
  45. Rename package name org.springaicommunity.mcp.context to org.springframework.ai.mcp.annotation.context
  46. Change the key of a Spring application property
  47. Change the key of a Spring application property
  48. Comment out Spring properties
  49. Comment out Spring properties
  50. Comment out Spring properties
  51. Comment out Spring properties
  52. Comment out Spring properties
  53. Comment out Spring properties
  54. Comment out Spring properties
  55. Comment out Spring properties
  56. Comment out Spring properties
  57. Migrate Spring AI properties to 2.0
  58. Migrate Spring AI dependencies to 2.0