Add ai-21-migration module: upgrading Spring AI 2.0.x to 2.1.0, measured. One probe source tree run on 2.0.0, 2.0.2, 2.0.3 and 2.1.0 (Anthropic prompt tokens with caching, auth header, discarded temperature, thinking parts, message mutability, entity() on refusals), three compile breaks, API and configuration diffs from the jars, ChatMemory to session copy, a wrapping ToolCallingManager under tool confirmation, the OpenAI Responses switch, VectorStore.upsert on real pgvector, a grep checklist and an OpenRewrite recipe. Scripted and local fake models; no provider called. Spring Boot 4.2.0, Spring AI 2.1.0, Java 25.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7N4ZDbUtA3ofqAqRV
This commit is contained in:
Claude
2026-12-03 09:46:46 +05:30
parent 8f69e7bf50
commit c8fa0912f7
71 changed files with 1990 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
# ai-21-migration
Companion code for [Spring AI 2.0 to 2.1 Migration Guide](https://ankurm.com/spring-ai-2-0-to-2-1-migration-guide/) on ankurm.com.
No model provider is called anywhere and no API key is needed. Chat models are scripted or are the real
Spring AI model classes pointed at a small local HTTP server written for this module. PostgreSQL with
pgvector is real, through Testcontainers.
## Versions
| | |
|---|---|
| Spring AI | 2.1.0 (probes also run on 2.0.0, 2.0.2, 2.0.3) |
| Spring Boot | 4.2.0 (probes on 2.0.x use 4.1.0) |
| JDK | 25 |
| OpenRewrite | rewrite-maven-plugin 6.46.1, rewrite-spring 6.37.1 |
## Layout
| Path | What it is |
|---|---|
| `probes/` | One source tree compiled and run against four Spring AI versions, so each difference is measured |
| `broken/src/` | Three files that compile on 2.0.3 and not on 2.1.0 |
| `src/` | The 2.1.0 replacement code and its tests |
| `legacy-app/` | A deliberately 2.0-style project, input for the checklist and the recipe |
| `rewrite.yml` | Two OpenRewrite recipes, to be run one after the other |
| `scripts/grep-checklist.sh` | Run it against your own project |
| `tools/ApiDiff.java` | Public API difference between two sets of jars (JDK class-file API) |
## Run
```bash
scripts/run-all.sh # everything; needs Maven, Docker and network access
mvn test # just the 2.1.0 module (Docker needed for UpsertTest)
(cd probes && mvn test -Dspring-ai.version=2.0.3 -Dboot.version=4.1.0)
scripts/grep-checklist.sh /path/to/project
```
Maven Central rate-limits bursts of downloads; if `api-diff.sh` stops with HTTP 429, wait and run it again.
## Captured output
| File | Shows |
|---|---|
| `output/01-usage-*.txt` | Anthropic prompt and total tokens with caching, per version |
| `output/02-request-*.txt` | Auth header, API version, sampling field and WARN lines |
| `output/03-thinking-*.txt` | Generations returned for a thinking reply |
| `output/04-messages-*.txt` | Message mutability and equality |
| `output/05-refusals-*.txt` | `entity()` on filtered and guarded replies |
| `output/06-legacy-warnings.txt` | javac removal warnings for 2.0-style code |
| `output/07-compile-breaks.txt` | The three compile errors |
| `output/08-session-migration.txt` | Copying `ChatMemory` into a session |
| `output/09-tool-manager.txt` | A wrapping `ToolCallingManager` and tool confirmation |
| `output/10-openai-api-switch.txt` | `spring.ai.openai.chat.api=responses` |
| `output/11-upsert.txt` | `VectorStore.upsert` on SimpleVectorStore and pgvector |
| `output/12-uncached.txt` | Full-price input tokens |
| `output/13-api-diff.txt` | Removed and newly deprecated API, 2.0.3 to 2.1.0 |
| `output/14-config-diff.txt` | Configuration property differences |
| `output/15-bom-diff.txt` | BOM artifacts and dependency versions |
| `output/16-grep-checklist.txt` | The checklist run on `legacy-app` |
| `output/17-openrewrite.txt` | The recipe's diff and the compile results |